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 :- Create a connection object to connect to the database.
- Create a recordset object in order to receive data in.
- Open the connection
- Populate the recordset by opening it and passing the desired table name or SQL statement as a parameter to open function.
- Do all the desired searching/processing on the fetched data.
- Commit the changes you made to the data by using Update or UpdateBatch methods.
- Close the recordset
- Close the connection
ASP example
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