Ken Lassesen
Microsoft Developer Network Technology Group
Created: July 31, 1995
Revised: October 11, 1995 (Updated diagram)
Click here for a diagram of the Data Access Object (DAO) in various graphics formats.
This article consists primarily of a graphic map of the Data Access Object (DAO), showing its properties, methods, and child objects. The map highlights changes between DAO version 2.5 and DAO version 3.0.
The Data Access Object (DAO) uses the Microsoft® Jet database engine to communicate with database servers via the Open Database Connectivity (ODBC) driver manager and a specified server driver (as shown in Figure 1). The DAO bypasses ODBC when the database is the Jet engine or another ISAM data source. This approach insulates the developer from many database-programming complexities while providing high-level data access objects, properties, and methods.
Figure 1. The relationship between the Data Access Object and other data components
The DAO is available in Visual C and many Visual Basic for Applications–based products. These include Microsoft Excel version 5.0 and higher, Microsoft Access 95, Visual Basic® version 4.0, and Visual C++™ version 4.0. The DAO may be used from other products that support references, for example, Microsoft Project. For information on using the DAO, see your product documentation and search the MSDN Library CD. The bibliography directs you to some key articles.
Table 1 shows the product heritage of the DAO.
Table 1. Version of DAO implementation in various products
DAO version | Microsoft products |
1.0 | Visual Basic 2.0, Visual Basic 3.0, Microsoft Access 1.1 |
2.0 | Microsoft Access 2.0 |
2.5 | Visual Basic 4.0 (16-bit only) |
3.0 | Visual Basic 4.0, Microsoft Access 95, Microsoft Excel 95, Visual C++ 4.0 |
Figure 2 shows the relationship between objects as described by the Object Viewer and online Help files. A map is a good learning aid and a quick reference when developing an application. After producing a map, I found that it was easy to work with the object: I just post the appropriate map on my wall for quick reference, which is a lot faster than clicking objects in a Help file one by one to discover their properties and methods. For an introduction to using OLE Automation see my article, "Using Microsoft OLE Servers to Develop Solutions."
Because Figure 2 is unreadable online, I have included the two most common graphics formats—encapsulated PostScript™ (.EPS) and Windows® metafile (.WMF)—as well as a copy of my original Shapeware® Visio™ version 4.0 file (.VSD). The first two formats can be printed across multiple pages using any of the commercial graphics applications—such as Adobe™ PageMaker™, Corel® Draw, or Microsoft® Publisher—or using Microsoft Excel. The original Visio file is included for those who have a copy of Visio 95 and wish to modify the diagram easily.
Figure 2. The Data Access Object map
DAO 3.0 has some methods and properties that may disappear in future versions. The Database.V1xNullBehavior property should not be used; it is included for backward compatibility.
The objects and collections in Figure 2 are defined in Table 2.
Table 2. Object and Collection Definitions
Object or Collection | Definition |
DBEngine object | This object represents the Microsoft Jet database engine. As the top-level object, it contains and controls all other objects in the hierarchy of data access objects. |
Workspaces collection | This collection contains all active, unhidden Workspace objects of the DBEngine object. |
Workspace object | This object defines a session for a user. It contains open databases and provides mechanisms for simultaneous transactions and for a secure workgroup. |
Databases collection | This collection contains all open Database objects opened or created in a Workspace object of the Microsoft Jet database engine. |
Database object | This object represents an open database. |
Errors collection | This collection contains all stored Error objects, each of which pertains to a single operation involving data access objects (DAO). |
Error object | This object contains details about data access errors. |
Users collection | This collection contains all stored User objects of a Workspace or group account. |
User object | This object is a user account that has access permissions when a Workspace object operates as a secure workgroup. |
Groups collection | This collection contains all stored Group objects of a Workspace or user account. |
Group object | This object is a group of user accounts that have common access permissions when a Workspace object operates as a secure work group. |
QueryDefs collection | This collection contains all QueryDef objects in a Database object. |
QueryDef object | This object is a stored definition of a query in a Microsoft Jet database. |
Parameters collection | This collection contains all the Parameter objects of a QueryDef object. |
Parameter object | This object is a parameter associated with a QueryDef object created from a parameter query. |
Recordsets collection | This collection contains all open Recordset objects in a Database object. |
Recordset object | This object consists of the records in a base table or the records returned from a query. |
TableDefs collection | This collection contains all stored TableDef objects in a database. |
TableDef object | This object represents the stored definition of a base table or an attached table. |
Indexes collection | This collection contains stored Index objects of a TableDef object. |
Index objects | These objects specify the order of records accessed from database. Index objects provide efficient access to data. For external databases, Index objects describe the indexes established for external tables. |
Relations collection | This collection contains stored Relation objects of a Database object. |
Relation object | This object is a relationship between fields in tables or queries. |
Containers collection | This collection contains all of the Container objects that are in a database. |
Container object | This collection contains information about objects grouped in that container. |
Documents collection | This collection contains all of the Document objects for a specific object. |
Document object | This object contains information about one instance of an object. The object can be a database, saved table, query, or relationship. |
Properties collection | This collection contains all the Property objects for a specific instance of an object. |
Property object | This object is a built-in characteristic or a user-defined characteristic of a data access object. |
Fields collection | This collection contains all stored Field objects of an Index, QueryDef, Recordset, Relation, or TableDef object. |
Field object | This object is a column of data with a common data type and a common set of properties. |
Black, Neil, and Stephen Hecht. "Jet Database Engine ODBC Connectivity." (MSDN Library Archive, Backgrounders)
Eineigl, Robert. "Basic Principles: Getting the Most from the Data Access Object Layer." Microsoft Developer Network News (May 1995). (MSDN Library, Periodicals)
Lassesen, Ken, "Using Microsoft OLE Servers to Develop Solutions." (MSDN Library, Technical Articles)
Mee, Michael. "Advanced Data Access Objects (DAO) for Client Server." (MSDN Library, Conference Papers)
Mee, Michael. "Forty-Two Ways to Make DAO Faster—Programming to DAO Using Microsoft Access." (MSDN Library, Conference Papers)
Nelson, Greg, and Roger Jennings. "A Client-Server Application: From Concept to Reality." (MSDN Library Archive, Conference Papers)