5.2. Using ADODB to Work with Data

In this section, you will explore the ADO object model and how to use the objects therein to work with data in underlying databases.

5.2.1. The ADO Object Model

Figure 5-1 provides an overview of the ADO object model. At the highest level of the object model, several collections exist: Connection, Recordset, Command, Record, and Stream.

Figure 5.1. Figure 5-1

The ADO object library is sometimes referred to as the ADODB library. In order to use the features of ADO, you must have a reference to one of the ADO library versions in your project. You can add a reference to an ADO library by selecting Tools References from Visual Basic Editor and choosing a library from the list. Figure 5-2 shows an example with a reference set to version ADO version 2.7.

Several versions of ADO may exist on your computer, such as 2.1, 2.5, 2.7, and 2.8. The version you choose for your project depends on the version of Access that others in your organization are using. If everyone is using Access 2007 or higher, you should use version 2.8. If everyone is using Access 2002 or higher, you should use version 2.7. If some people are using Access 2000, then you may want to use ADO version 2.5. If some are using Access 97, you may want to use ADO version 2.1.

The examples ...

Get Beginning Access™ 2007 VBA 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.