The ADO Object Model

OLE DB is designed for C programmers. In order to make it accessible to VB programmers, Microsoft created the ADO object model. This model gives VB programmers access to certain aspects of the OLE DB paradigm, by allowing the programmer to program an object model, rather than having to use the OLE DB API functions directly. For instance, a VB programmer can get access to a data provider by creating a Connection object and setting its Provider property. Thus, the Connection object represents a connection to a data store, through a data provider.

The ADO object model is actually quite small, even smaller than the DAO object model. Table 17.1 shows the complete list of ADO objects (along with corresponding collection objects).

Table 17-1. The ADO Objects

Command

Connection

Error (Errors)

Field (Fields)

Parameter (Parameters)

Property (Properties)

Recordset

The ADO object model is shown in Figure 17.3. Unlike the DAO model, which has a single object (DBEngine) at the top of the model, the ADO object model is headed by a triumvirate of three externally creatable objects: Command, Connection, and Recordset. (The Parameter object is also externally creatable.)

An externally creatable object is an object that can be created directly using the VBA New operator, as in:

Dim rs As New Recordset

or, alternatively:

Dim rs As Recordset
Set rs = New Recordset

Thus, as we will see, unlike DAO, a Recordset object can be created independently at the “beginning” of an ADO session. ...

Get Access Database Design and Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.