ActiveX Data Objects

related topics
{math, number, function}
{system, computer, user}

Microsoft's ActiveX Data Objects (ADO) is a set of Component Object Model (COM) objects for accessing data sources. A part of MDAC, it provides a layer between programming languages and OLE DB (a means of accessing data stores, whether they be databases or otherwise, in a uniform manner). ADO allows a developer to write programs that access data without knowing how the database is implemented. You must be aware of your database for connection only. No knowledge of SQL is required to access a database when using ADO, although one can use ADO to execute SQL commands. The disadvantage of this (i.e. using SQL directly) is that it introduces a dependency upon the type of database used.

It is positioned as a successor to Microsoft's earlier object layers for accessing data sources, including RDO (Remote Data Objects) and DAO (Data Access Objects). ADO was introduced by Microsoft in October 1996.



ADO is made up of four collections and twelve objects:

ADO collections

ADO objects

  • an OLE DB provider (for example SQLOLEDB), using the syntax "provider=";
  • a file name, using the syntax "file name=";
  • a remote provider and server (see RDS), using the syntax "Remote provider=" and "Remote server="; or
  • an absolute URL, using the syntax "URL="

Basic usage

Some basic steps are required in order to be able to access and manipulate data using ADO :

ASP example

Here is an ASP example using ADO to select the "Name" field, from a table called "Phonebook", where a "PhoneNumber" was equal to "555-5555".

dim myconnection, myrecordset, name
set myconnection = server.createobject("ADODB.Connection")
set myrecordset = server.createobject("ADODB.Recordset") mydatasource "Phonebook", myconnection 
myrecordset.find "PhoneNumber = '555-5555'"
name = myrecordset.fields.item("Name")
set myrecordset = nothing
set myconnection = nothing

This is equivalent to the following ASP code, which uses plain SQL instead of the functionality of the Recordset object:

dim myconnection, myrecordset, name
set myconnection = server.createobject("ADODB.connection") mydatasource
set myrecordset = myconnection.execute("SELECT Name FROM Phonebook WHERE PhoneNumber = '555-5555'")
name = myrecordset(0)

[edit] Software support

ADO is supported in ASP, CodeGear Delphi, PowerBuilder, and in Visual Basic for Applications (VBA).

[edit] See also


[edit] External links