Home ASP Main

ActiveX Data Objects (ADO)



ActiveX Data Objects (ADO) enables you to write an application to access and manipulate data in a database server through an OLE DB provider. ADO's primary benefits are high speed, ease of use, low memory overhead, and a small disk footprint.


ADO Features

ADO supports key features for building client/server and web-based applications, including the following:

Independently-created objects. Unlike Data Access Objects (DAO) or Remote Data Objects (RDO), you no longer have to navigate through a hierarchy to create objects because most ADO objects can be independently created. This allows you to create and track only the objects you need, and also results in fewer ADO objects and thus a smaller working set.

Batch updating helps improve performance by locally caching changes to data, then writing them all to the server in a single update.

Support for stored procedures with in/out parameters and return values.

Different cursor types, including the potential for support of back-end–specific cursors.

Support for limits on number of returned rows and other query goals for performance tuning.

Support for multiple recordsets returned from stored procedures or batch statements.

Free-threaded objects for efficient web server applications.


ADO is a dual-interface COM type library. The filename is msado15.dll. The program ID (ProgID) is "ADODB." In 2 and 3 tier database applications, ADO code that is to execute on the client uses the ProgID "ADOR" instead.

To use ADO with Microsoft Visual Basic or Microsoft Office, you also need to establish a reference to the ADO type library. Select References from the Project menu, check the box for "Microsoft ActiveX Data Objects 1.5 Library," and then click "OK." ADO objects, methods, and properties will then be accessible through the VBA Object Browser and the IDE Editor.

To use ADO with Microsoft Visual J++, you also need to create a set of class files using the Java Type Library Wizard. Select the Java Type Library Wizard from the Tools menu, check the box for "Microsoft ActiveX Data Objects 1.5 Library," and then click "OK." The wizard will then create the necessary Java class files for ADO.

For some programming languages, you also need to reference (using the #include statement) one or more additional files in your source code, as shown in the table below:
For C++ - adoint.h, adoid.h
For VBScript - adovbs
For JScript - adojavas.inc

Threading

The ADO library is free-threaded, but listed in the Windows Registry as apartment model. The thread safety of ADO depends on the underlying provider and data source. For example, the Microsoft OLE DB Provider for ODBC is free-threaded, but not all ODBC drivers are. You should use ADO as apartment model unless you can verify that all of the underlying components can be used free-threaded.


ADO Objects


Although ADO objects are creatable outside the scope of a hierarchy, the objects exist within hierarchical relationships, as shown in the ADO Object Model.

There are 7 objects in the ADO object model:

Command

Maintains information about a command, such as a query string, parameter definitions, etc. You can execute a command string on a Connecton object or 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.

Connection

Maintains connection information with the data provider.

Error

Contains extended error information about an error condition raised by the provider. Since a single statement can generate two or more errors, the Errors collection can contain more than one Error object at a time, all of which result from the same incident.

Field

Contains information about a single column of data within a Recordset. The Recordset object features a Fields collection to contain all of its Field objects.

Parameter

A single parameter for a parameterized Command. The Command object features a Parameters collection to contain all of its Parameter objects.

Property

A provider-defined characteristic of an ADO object.

Recordset

A set of records returned from a query, and a cursor into those records. You can open a Recordset (i.e., 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.
Each of these objects features a set of properties and methods with which you can manipulate the object and its contents.


Cool links for more information on ADO

TOP TEN TIPS: ACCESSING SQL THROUGH ADO AND ASP

FAQ