Partager via


Visual Basic Concepts

The ADO 2.0 Object Model

The ADO 2.0 object model is composed of eight objects, most of them similar in functionality to RDO objects, only with enhanced functionality. Spend some time browsing the object model in the Object Browser (F2) to become familiar with the location of the various properties, methods, events, collections, and so forth.

Note   All objects followed by an asterisk (*) are objects that also apply to the ADO Recordset type library (ADOR).

  • Command object   Contains information about a command, such as a query string, parameter definition, and so forth. The Command object is similar in functionality to RDO's rdoQuery object.

  • Connection object   Contains information about a data provider. The Connection object is similar in functionality to RDO's rdoConnection object, and it contains the information on schema. It also contains some of the functionality of the RDOEnvironment object, such as transaction control.

  • Error object   Contains extended information when an error occurs with a data provider. The Error object is similar in functionality to RDO's rdoError object. In comparison to RDO, however, the Errors collection is on the Connection object, whereas the rdoErrors collection is on the rdoEngine object in RDO 2.0.

  • Field object*   Contains information about a single column of data in a recordset. The Field object is similar in functionality to RDO's rdoColumn object.

  • Parameter object   Contains a single parameter for a parameterized Command object. The Command object has a Parameters collection to contain all of its Parameter objects. The Parameter object is similar in functionality to RDO's rdoParameter object.

  • Property object*   Contains a provider-defined characteristic of an ADO object. There is no RDO equivalent to this object, but DAO has a similar object. ADO objects can have two kinds of properties:

    • Built-In Properties: Properties which are "native" to ADO. That is, properties in ADO that are immediately available to any new object using the familiar MyObject.Property syntax. Built-in properties do not appear as Property objects in an object’s Properties collection, so while you can change their values, you can't modify their characteristics or delete them.

    • Dynamic properties: Properties which are not native to ADO and are defined by the underlying data provider. They appear in the Properties collection of the appropriate ADO object.

      For example, a property specific to the data provider may indicate if a Recordset object supports transactions or updating. These additional properties appear as Property objects in the Recordset’s Properties collection. Dynamic properties can be referred to only through the collection using the MyObject.Properties(0) or MyObject.Properties("Name") syntax. Different data providers may implement one or more special properties to deal with special provider-specific operations.

  • Recordset object*   The Recordset object contains records returned from a query as well as a cursor into those records. The Recordset object is similar in functionality to RDO's rdoResultset object. You can open a Recordset (for example, perform a query) without explicitly opening a Connection object. If, however, you choose to create a Connection object, you can open multiple Recordset objects on the same connection.