Understanding the ADO Object Model
The ADO object model defines a collection of programmable objects that support the Component Object Model (COM) and OLE Automation to leverage the powerful partner technology called OLE DB. The ADO object model — when compared to other data access objects such as RDO or DAO — is flatter (has fewer objects) and simpler to use.
The following drawing shows the ADO object model.
There are seven objects in the ADO object model, as described in the following list.
-
Command object Maintains information about a command, such as a query string, parameter definitions, and so on. You can execute a command string on a Connection object of a query string as part of opening a Recordset object, without defining a Command object. The Command object is useful where you want to define query parameters or execute a stored procedure that returns output parameters. The Command object supports a number of properties to describe the type and purpose of the query and help ADO optimize the operation.
-
Connection object Maintains connection information such as cursor type, connect string, query time-out, connection time-out, and default database.
-
Error object Contains extended error information about error conditions raised by the data provider. Because a single statement can generate two or more errors, the Errors collection can contain more than one Error object at a time.
-
Field object Contains information about a single column of data within a recordset. The Recordset object uses the Fields collection to contain all of its Field objects. This Field information includes data type, precision, and numeric scale.
-
Parameter object A single parameter associated with a Command. The Command object uses the Parameters collection to contain all of its Parameter objects. ADO Parameter objects can be created automatically by sending queries to the database. However, you can also build this collection programmatically to improve performance at run time.
-
Property object A provider-defined characteristic of an ADO object. ADO objects have two types of properties: built-in and dynamic. Built-in properties are those properties implemented in ADO and available to any new ADO object. Dynamic properties are defined by the underlying data provider and appear in the Properties collection for the appropriate ADO object. For example, a property may indicate if a Recordset object supports transactions or updating. This is one of the greatest features of ADO, in that it lets the ADO service provider present special interfaces.
-
Recordset object A set of rows returned from a query, including a cursor into those rows. You can open a Recordset object (that is, execute a query) without explicitly opening a Connection object. However, if you do first create a Connection object, you can open multiple Recordset objects on the same connection.