Activex Data Objects ADO

Intermediate

ActiveX Data Objects (ADO) is a high-level programming interface from Microsoft for accessing data sources. As a set of COM components, it provided a unified and easy-to-use layer over OLE DB, allowing developers in languages like Visual Basic 6 and VBScript (in classic ASP) to connect to and manipulate data from both relational and non-relational databases. It was the primary data access technology for Microsoft platforms before the introduction of ADO.NET.

First used·1996

Definitions·1

Synonyms·1

Category·Data Access Technology

Also known as

Classic ADO

Definitions

What it means.

  1. 01

    Microsoft's COM-based Data Access API

    ActiveX Data Objects (ADO) is a high-level application programming interface (API) from Microsoft that provides a standardized way to access and manipulate data from a variety of sources. It is implemented as a set of Component Object Model (COM) objects, making it accessible from most Windows programming and scripting languages from its era.

    ADO acts as an abstraction layer on top of OLE DB, which allows it to connect to any data source for which an OLE DB provider exists. This includes relational databases (SQL Server, Oracle), non-relational sources (file systems, email servers), and data accessed via an ODBC driver.

    Core Objects

    The ADO object model is relatively simple and consists of a few key objects:

    • Connection: Represents an open connection to a data source. It is used to establish the session, configure connection strings, and manage transactions.
    • Command: Represents a specific command you want to execute against the data source, such as a SQL statement, a stored procedure, or a table name.
    • Recordset: This is the central object in ADO. It represents the entire set of records resulting from a query. You can use it to navigate through rows, and to add, update, or delete records. It functions like a cursor into the data.
    • Parameter: Used to add parameters to a Command object, which is crucial for preventing SQL injection and calling stored procedures.
    • Field: Represents a single column of data within a Recordset.

    Example Usage (VBScript in classic ASP)

    ' Create ADO objects
    Set conn = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Recordset")
    
    ' Define the connection string and open the connection
    conn.Open "Provider=SQLOLEDB;Data Source=myServer;Initial Catalog=myDB;User Id=myUser;Password=myPassword;"
    
    ' Define the SQL query and execute it
    sql = "SELECT FirstName, LastName FROM Employees"
    rs.Open sql, conn
    
    ' Loop through the recordset and display data
    Do While Not rs.EOF
      Response.Write(rs("FirstName") & " " & rs("LastName") & "<br>")
      rs.MoveNext
    Loop
    
    ' Clean up
    rs.Close
    conn.Close
    Set rs = Nothing
    Set conn = Nothing
    

    This example demonstrates the typical workflow: create and open a connection, define and execute a query to populate a recordset, iterate through the records, and finally, close the connection and release the objects. This model, often referred to as Classic ADO, was the cornerstone of data-driven web and desktop applications on the Microsoft platform before the rise of .NET.

Origin

Where it comes from.

Etymology

The name is derived from its components. 'ActiveX' was Microsoft's brand name for its COM-based technologies designed for network and internet environments. 'Data Objects' refers to its object-oriented model, where data and data operations are encapsulated in objects like Connection, Command, and Recordset.

Historical context

The history of Microsoft's data access strategies shows a clear evolution. In the early 1990s, developers used Data Access Objects (DAO) for Jet databases (like Microsoft Access) and Remote Data Objects (RDO) for accessing relational databases like SQL Server via ODBC.

These two separate APIs created a fragmented development experience. To solve this, Microsoft introduced OLE DB (Object Linking and Embedding, Database) as a low-level, universal data access layer capable of connecting to any data source through providers, not just relational databases.

However, OLE DB was complex to program against directly. In 1996, Microsoft released ActiveX Data Objects (ADO) 1.0 as part of the Microsoft Data Access Components (MDAC) stack. ADO served as a high-level, easy-to-use wrapper around OLE DB. It unified data access into a single, simplified object model, quickly becoming the standard for developers using Visual Basic 6, classic ASP, and other COM-aware environments.

With the launch of the .NET Framework in 2002, ADO was succeeded by ADO.NET. The new framework was designed for the disconnected, stateless nature of the web and introduced a new paradigm for data access, marking the decline of Classic ADO for new development.

Usage

In context.

  • In our legacy Visual Basic 6 application, we still use ActiveX Data Objects (ADO) to connect to an old Access database.

  • The classic ASP page uses a VBScript with an ADO Connection object to query the SQL Server and display the results in an HTML table.

  • To distinguish it from its .NET successor, developers often refer to the original COM-based version as Classic ADO.

FAQ

Common questions.

The primary purpose of ADO was to provide developers with a single, high-level, and consistent programming interface for accessing a wide variety of data sources. It was designed to abstract away the complexities of lower-level data access APIs like OLE DB and ODBC, making it easier and faster to write data-driven applications in COM-enabled languages such as Visual Basic, VBScript, and C++.

Taxonomy

Filed under.

Categories

Data Access TechnologyMicrosoft TechnologiesLegacy Technology

Tags

MicrosoftData AccessCOMDatabaseAPIWindows