Objects

ADO and SQL Server

ADO and SQL Server

Objects

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++®, and 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 nine objects and four collections, is designed to expose the most commonly used features of OLE DB.

The following diagram shows the relationships among the ADO objects and collections:

The Connection, Command, and Recordset objects are the most commonly used ADO objects.

  • The Connection object is used to establish connections between the client and database server.

  • The Command object is used to issue commands, such as SQL queries and updates, to the database.

  • The Recordset object is used to view and manipulate the results of the query.

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, and through the Row object.

The Properties collection provides information about the characteristics of the Connection, Command, Recordset, Row, Field, and Stream objects. Each Property object belonging to the Properties collection must be accessed through one of those six objects.

Although ADO defines an object hierarchy, all ADO objects except for 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 object or the Command object.

See Also

Using the Fields Collection and Field Object

Using Parameters