ActiveX Data Objects


In computing, Microsoft's ActiveX Data Objects comprises a set of Component Object Model objects for accessing data sources. A part of MDAC, it provides a middleware layer between programming languages and OLE DB. ADO allows a developer to write programs that access data without knowing how the database is implemented; developers must be aware of the 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 directly.
Microsoft introduced ADO in October 1996, positioning the software as a successor to Microsoft's earlier object layers for accessing data sources, including RDO and DAO.
ADO is made up of four collections and twelve objects.

ADO collections

; Fields
; Properties
; Parameters
; Errors

ADO objects

; Connection
; Command
; Recordset
; Immediate
; Batch
; Transaction
; Record
; Stream
; Parameter
; Field
; Property
; Error

Basic usage

Some basic steps are required in order to be able to access and manipulate data using ADO :
  1. Create a connection object to connect to the database.
  2. Create a recordset object in order to receive data in.
  3. Open the connection
  4. Populate the recordset by opening it and passing the desired table name or SQL statement as a parameter to open function.
  5. Do all the desired searching/processing on the fetched data.
  6. Commit the changes you made to the data by using Update or UpdateBatch methods.
  7. Close the recordset
  8. Close the connection

    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
set myrecordset = server.createobject
myconnection.open mydatasource
myrecordset.open "Phonebook", myconnection
myrecordset.find "PhoneNumber = '555-5555'"
name = myrecordset.fields.item
myrecordset.close
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
myconnection.open mydatasource
set myrecordset = myconnection.execute
name = myrecordset

Software support

ADO is supported in any development language that supports binding to binary COM interfaces. These languages include ASP, Delphi, PowerBuilder, and Visual Basic for Applications. ADO support has now been added to dBase Plus 8

Legacy

ADO.NET has replaced ADO in the same way that C#/.NET replaced C/Win32 as the primary mode for targeting Windows application development. ADO.NET follows the same design pattern as ADO, enabling an ADO developer an easy path forward when moving to the.NET framework.