The ADO object model defines a collection of programmable objects that can be used by any of the Microsoft Visual languages (Microsoft® Visual Basic®, Microsoft Visual C++®, Microsoft Visual J++™); Web scripting languages such as Visual Basic Scripting Edition and Microsoft JScript®; and generally, any platform that supports both COM and Automation. The ADO object model, which contains seven objects and four collections, is designed to expose the most commonly used features of OLE DB.
The following figure shows the relationships among the ADO objects and collections:
The Connection, Recordset, and Command objects are the most important ADO objects. ADO applications typically use the:
Use the Parameters collection and Parameter objects when the query in the Command object requires parameters. The Errors collection and Error object are accessed through the Connection object after a provider error occurs. The Fields collection and Field object are accessed through the Recordset object after data exists in the Recordset object.
The Properties collection provides information about the characteristics of the Connection, Command, Recordset, and Field objects. Each Property object belonging to the Properties collection must be accessed through one of those four objects.
Although ADO defines an object hierarchy, all ADO objects except the Error, Field, and Property objects can be created on their own. (This differs somewhat from the DAO and RDO object models, where an object must often be qualified with its parent objects when used.)
Because ADO offers flexibility in defining programmable objects, there are often several ways of accomplishing the same task. For example, to execute a query, you can use the Execute method of either the Connection or Command object.