Visual Basic Reference

Visual Studio 6.0

DataSource Property

See Also    Example    Applies To

Returns or sets a data source through which a data consumer is bound to a database.


object.DataSource [=datasource]

The DataSource property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
datasource An object reference that qualifies as a data source, including ADO Recordset objects, and classes or user controls defined as data sources (DataSourceBehavior property = vbDataSource). 


Use the Set statement to set the DataSource property, as shown below:

Set Text1.DataSource = ADODC1

Note   Two older controls, the Data control and RemoteData control, can be used as data sources, however you cannot set the DataSource property of another control or object to either of these controls at run time. For example, the following code will fail:

Set Text1.DataSource = Data1    ' Will fail! You can't set DataSource at 
                              ' run time to an intrinsic Data control.

To use either the Data control or RemoteData control as a data source, you can set the DataSource property of bound controls at design time only.