News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Set the DBGrid's DataSource property to the Data control.

Started by nandagopal, May 20, 2009, 07:01 PM

Previous topic - Next topic

nandagopal

Place a DBGrid and Data control on the form. Set the DBGrid's DataSource property to the Data control. Set other properties such as AllowAddNew, AllowDelete, and AllowUpdate as desired.

Set the Data control's DatabaseName property to the database. This example sets the database name at runtime like this:


Private Sub Form_Load()
    Data1.DatabaseName = App.Path & "\CoData.mdb"
End Sub


Set the Data control's RecordSource property to the SQL SELECT statement the control should use to pick the data to be displayed. In this example, the property is set to:

    SELECT Name, Department, Manager
    FROM Employees, Departments
    WHERE Employees.Department =  Departments.DepartmentName

The DBGrid control displays the data automatically.