DataSource Property (ActiveX Controls)
Collapse the table of content
Expand the table of content

Visual Basic Reference

Visual Studio 6.0

DataSource Property (ActiveX Controls)

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 DataGrid1.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.

© 2016 Microsoft