Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 8

Binding VB Controls to the ADO Data Control's Recordset in VB6

When the form containing the ADO Data Control loads into memory, the ADO Data Control will connect to data using the ConnectString property and return a Recordset fitting the specifications of the RecordSource property.

To see any of the information in the records, you will have to put VB controls on the form and bind them to specific fields in the ADO Data Control's Recordset. Follow these steps to bind controls to the ADO Data Control's Recordset:

STEP BY STEP
8.6 Binding Controls to the ADO Data Control's Recordset

  1. Place a VB control such as a TextBox on the form.

  2. In the control's Properties window, activate the drop-down list on the DataSource property. The list will include the names of any ADO Data Controls on the current form, any Data Environment Designers in the current project, and any other types of DataSource (such as RDO or DAO Data Controls) available to this control (see Figure 8.21).

    Setting the DataSource property for a control that you will bind to an ADO Data Control or another data source.
    FIGURE 8.21 Setting the DataSource property for a control that you will bind to an ADO Data Control or another data source.

  3. Choose as the DataSource the ADO Data Control whose Recordset you want to bind this control to.

  4. Now set the control's DataField property by activating the drop-down list belonging to the DataField property in the Properties window. You should see a list of fields available from the ADO Data Control's Recordset. Choose the field that you want to bind to this control (see Figure 8.22).

    Setting the DataField property of a bound control.
    FIGURE 8.22 Setting the DataField property of a bound control.

  5. The control is now bound to the desired field in the Recordset.

After you have bound controls to the ADO Data Control, you can run the project to test the connection. You should see data from the Recordset displayed in the bound controls. When you click the ADO Data Control's navigation buttons, you should see the contents of the bound controls change as the Recordset's cursor move through different records.

Depending on the cursor options that you have chosen, you might also see that you can make changes to the underlying data fields by changing the contents of the bound controls

See Also


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved