Visual Basic Concepts

Binding Data to Your Data Environment

Data-bound controls are the data-aware controls through which you can display information from a database. You can bind these data-aware controls to Command objects that have been defined in a DataEnvironment object. At run-time, Visual Basic automatically opens these Command objects and their associated connections.

At run time, up to three data-aware properties define what the controls are bound to. The following table describes the controls you should use to set the data-aware properties of a Data Environment's Recordset object or Recordset field.

Property Description
DataSource Specifies the name of the DataEnvironment object to be used as the data source, such as DataEnvironment1.
DataMember Specifies the name of the Command object in the DataSource, such as Customers.
DataField Specifies the name of the Field object from the DataMember, such as Country.

To bind a Visual Basic control to a DataEnvironment object

  1. Drop a control, such as a TextBox, onto your Visual Basic form.

  2. On the Properties window, click the DataSource property and select the DataEnvironment object that you wish to bind to your control.

  3. Click the DataMember property and select the Command object within the Data Environment that contains the field that you wish to bind to your control.

    Note   When binding to a Command object that contains parameters, make sure the parameters contain a valid value in their Value property.

  4. Click the DataField property, if applicable, and select the field from the Command object that you wish to bind to your control.