PreviousTutorials and Guide to Samples (9.1 revision 1) Next

Lesson 2: Using the ADO Data Control (ADODC)

Show this topic in Library frames

Microsoft's ADO Data control (ADODC) provides the simplest way to create an application, because you can perform many data access and manipulation tasks without writing any code. By binding data controls to an existing database, you can greatly simplify your programming efforts.

This lesson binds the ADO Data control to a bound DataGrid control in order to display data from the Course table of the sample database.

To create a bound DataGrid control using Pervasive's OLE DB provider:

  1. Click on the ADO Data control in the Toolbox.

  2. Drag your cursor in the Form1 window to create an ADO Data control.

  3. An ADO Data control allows you to access data. In this case, you will be accessing Pervasive data via OLE DB. You specify this using the Properties window, which you configure in the next step.

  4. Right-click the Adodc control on the Form1 window. Choose "ADODC Properties". Click the "Build" button.

  5. Choose "Pervasive OLE DB Provider". Click the "Next >>" button.

  6. Type "MyDemodata" (or whatever you used for your database name). Click "OK".

  7. Click on the "RecordSource" tab. Change "Command Type" to "2 - adCmdTable". Type or select "Room" in the "Table or Stored Procedure Name" combo box. Click "OK".

  8. Click on the DataGrid control in the Toolbox.

  9. Drag your cursor in the Form1 window to create a DataGrid control.

  10. The DataGrid control can display data accessed by an ADO Data control. In this case, you will be accessing the Adodc1 control you created in Step 2. You specify this using the Properties window, which you configure in the next step.

  11. In the DataSource field of the Properties window, select "Adodc1".

  12. Click the Start button on the Toolbar.

  13. Visual Basic runs the application and displays the results. This shows all the records in the Room table. You can navigate through the rows using the scroll bars or the arrows in the Adodc1 control.

  14. When finished scrolling through the records, close the application and return to the form design view.

To create a bound DataGrid control using Microsoft's OLE DB for ODBC Driver provider:

  1. Right-click the Adodc control on the Form1 window. Choose "ADODC Properties". Click the "Build" button.

  2. Click on the "Provider" tab. Choose "Microsoft OLE DB Provider for ODBC Drivers". Click the "Next >>" button.

  3. Choose "MyDemodata" (or whatever you used for your database name) in the "Use data source name" combo box. Click "OK".

  4. Click on the "RecordSource" tab. Delete the table name "Room" from the "Table or Stored Procedure Name" combo box. Change "Command Type" to "1 - adCmdText". Type SELECT * FROM Room in the Command Text (SQL) box. Click "OK".


Chapter contents
Publication contents

Prev topic: Lesson 1: Setting Up Your Environment
Next topic: Lesson 3: Writing Code with ActiveX Data Objects