Team LiB
Previous Section Next Section

Chapter 1: Data Access Models: Part I

Overview

Microsoft Access 2003 supports two data access models: the traditional Data Access Objects (DAO) and ActiveX Data Objects (ADO). ADO is part of the Microsoft Data Access Components (MDAC), which initially targeted universal data access. DAO targets just the Jet database engine. DAO was the exclusive data access model for Access developers from Access 1.0 through Access 97. Therefore, it is finely tuned to the Jet database engine. This feature is both a strength and a weakness. While DAO can still perform a few selected tasks for the Jet engine that are impossible or very difficult to do with ADO, accessing data from sources other than Jet using DAO can be very awkward or impossible, depending on the context.

Access 2000 was the first Access version to support ADO for data access to Jet as well as to other databases. ADO is a separate technology from Microsoft Access, but Access interoperates well with it. With Access 2002 and Access 2003, Microsoft improved on past functionality and added new capabilities to ADO programming. Instead of being based on a single database engine (such as DAO), ADO uses a common programming model to access data universally. It relies on OLE DB providers for low-level links to data sources. OLE DB technologies eventually will make their ODBC predecessors obsolete, much as ADO will replace DAO. In fact, the MDAC Road Map (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmdac/html/data_mdacroadmap.asp) already describes DAO as an obsolete data access technology. This means that the current 3.6 version of DAO will not be updated in the future. The road map advises against building new systems with obsolete technologies and encourages migrations to ADO or ADO.NET for any modifications of existing applications. The road map describes ADO.NET as an evolutionary progression from ADO. ADO.NET is the data component for the .NET Framework, Microsoft's next-generation application development environment. See my Programming Microsoft Visual Basic .NET for Microsoft Access Databases (Microsoft Press, 2002) book for numerous code samples illustrating the use of ADO.NET with Access .mdb files.

ADO was conceived as a universal data access language, and it is highly suitable for developing solutions based on the Web or on a LAN (local area network). DAO does not process data when used in a Web-based solution. Because of its limited scope and obsolete status, DAO does not play a significant role in this book. For information on DAO code, see the online documentation for Access and Microsoft's Support Online (http://support.microsoft.com/). Click the Searchable Knowledge Base link for documents that discuss typical problems and their associated workarounds. Many of the articles include DAO code samples.

The subject of data access models is vast. To make this discussion more digestible, I've broken it into two chapters. This chapter and Chapter 2 focus primarily on data access for Jet with the ADO object model. The two chapters also include some coverage of ADO with other database engines, particularly with Microsoft SQL Server. Numerous programming samples show you how to accomplish typical database chores.

This chapter begins with an overview of ActiveX Data Objects and then moves on to discuss the Connection, Recordset, and Field objects. This chapter aims to convey a basic understanding of the kinds of roles each object plays, as well as how to code the objects. In Chapter 2, you will learn about the Command and Parameters objects and the Errors collection. Chapter 2 also devotes considerable attention to demonstrating the features of the ADO Record and Stream objects. Chapter 2 closes with a review of ADO event programming techniques. Later chapters build on the information presented in Chapter 1 and Chapter 2 and cover advanced data topics, such as database replication, remote database access, and multiuser security.


Team LiB
Previous Section Next Section