Using ADO to Access Data

In the last chapter, you were introduced to one of the two data access models that Access supports: Data Access Objects (DAO). In this chapter, we will closely examine the other model: ActiveX Data Objects (ADO).

Recall from Chapter 6 that DAO was the default data access technology in the early versions of Access. In fact, Access was bound so closely to the Jet database engine by the fact that developers used Access as both the front-end user interface and the back-end data store that they rarely felt a need for anything else. As applications design evolved from standalone to client/server architectures, the need to connect to and access data from disparate data sources became more and more important. Although Microsoft made several attempts at evolving DAO into a remote data access technology, its real forte was in accessing data from local Jet databases. This is where ADO comes in. When you need to connect to external data sources, you need to start using ADO, because ADO is specifically designed to connect to a wide variety of external data sources.

ADO is a part of Microsoft's data access vision of the future, called Universal Data Access (UDA), in which a single method is used to retrieve data from any data source, which may include relational databases, the mainframe indexed sequential access method/virtual storage access method (ISAM/VSAM), hierarchical databases, e-mail, disk files, graphical data, and so on.

OLE DB (Object Linking and Embedding Databases) is the interface that enables UDA. ADO is a development interface for OLE DB and replaces both DAO and RDO.

OLE DB sees the world in terms of data providers, which act as an interface between the data source and the consumer of the data. Although OLE DB was written for procedural programming models, ADO sits atop OLE DB, providing programmers with an object-oriented model they can use to access and manipulate the data sources.

When you use Access 2003 to create a standard Jet database (MDB), by default, Access uses the Jet OLE DB provider to manage the connection to the data store. Confirm this by entering the following line of code in the Visual Basic Editor's Immediate window:

?CurrentProject.Connection

You'll see the returned connection string begins with the following:

Microsoft.Jet.OLEDB.4.0;

Similarly, Access uses the Access OLE DB provider when you create an Access Data Project (ADP) against the SQL Server or MSDE. The same property call returns a connection string that begins thus:

Microsoft.Access.OLEDB.10.0;

0 0

Post a comment