Creating a Simple Database Application with the DataGrid and ADO Data Control

See Also

Using only a DataGrid and an ADO Data control you can create a database application that allows the end user to read and write to a recordset.

Create a simple database application using the ADO Data Control

  1. Create an OLE DB data source for the Northwind database.

    If a Data Source has not been created, follow the steps in "Creating the Northwind OLE DB Data Link."

  2. Create a new Standard EXE project in Visual Basic.

    If the DataGrid control is not present in the Toolbox, right-click the Toolbox, and use the Components dialog box to load it. Also load the ADO control.

  3. Place an instance of each control on the blank form.

  4. Set the ADO Control's ConnectionString property to the Northwind data source.

    Click the ADO Data control to select it, and press F4 to make the Properties window appear. Click ConnectionString and then click OLE DB File. Click the Northwind Data Source.

  5. Set the ADO Control's RecordSource property.

    On the Properties window, click RecordSource and type a SQL statement to populate the DataGrid control. In this case, type in Select * From Products.

  6. Set the DataGrid Control's DataSource property to the ADO Data control.

    Click the DataGrid control to select it. On the Properties window, click DataSource and a drop-down list of all data controls will be presented — in this case only the ADO Data control. Click the control.

  7. Press F5 to run the project.