SQL Seven - 01 Oct 1999

Microsoft designed the ADO model to expose the functionality of the OLE DB API to client applications. The OLE DB API provides a low-level interface to many data sources, and ADO provides a higher-level COM-based set of objects.

1. Connection

The Connection, Command, and Recordset objects are the three core components of the ADO model. The Connection object lets your ADO applications establish a link to the target data source. Then, you can use the Connection object to directly execute SQL statements, or the Command and Recordset objects can use the Connection object. To establish a link to the data source, you use the Open method. To terminate that link, use the Close method.

2. Command

You use the Command object to issue commands to the data source. For a SQL Server data source, these commands consist of dynamic SQL statements, prepared SQL statements, or stored-procedure calls. The CommandText property contains the command, and the Execute method runs the command.

3. Parameter

You use Parameter objects with the Command object. Parameter objects specify the individual attributes for each para-meter that a Command object uses. Developers often use the Command object's CreateParameter method to create Parameter objects. The Command object's Parameters collection contains all the Parameter objects for a given Command object.

4. Recordset

Developers probably use the Recordset object more frequently than any other object in ADO. The primary purpose of the Recordset object is to send SQL queries to SQL Server and return the query results to the client application. The Recordset object's Source property contains the SQL statement or query. You typically use the Recordset object's Open method to execute the query on the server, and the query populates the recordset for the client application.

5. Field

Used with the Recordset object, each Field object represents a column that's contained in the recordset. The Field object's properties reflect the column's data type, size, and value. The Fields collection, which is built automatically when the Recordset object's Open method executes, contains all the Field objects for each Recordset object.

6. Property

The Property object provides information about various characteristics of the Connection, Command, Recordset, and Field objects. You can access Property objects through each of these ADO objects. The Properties object provides a method for each OLE DB provider to expose unique functionality.

7. Error

As its name suggests, the Error object lets you retrieve ADO runtime error information. Although methods in the Connection, Command, or Recordset objects can generate ADO errors, the Connection object's Errors collection always contains a record of the error information. The Error object's Description property contains a text description of the error and the SQLState property returns ODBC or OLE DB error codes with more specific information about an error condition.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.