DAO Workspace: The Database Engine
| Overview | How Do I | FAQ | Sample | | ODBC Driver List
MFC and DAO use the Microsoft Jet database engine, currently version 3.0, to retrieve data from and store data in user and system databases. The Microsoft Jet database engine is the data manager component on which various implementations are built, such as the MFC DAO classes, Microsoft Access, and Microsoft Visual Basic, and the Microsoft Desktop Database Drivers (currently version 3.0).
This article explains how you interact with the database engine via MFC. Topics covered include:
Data sources you can access
How MFC exposes the database engine
Database engine collections
Initializing and uninitializing the database engine
Data Sources You Can Access
While the database engine is best suited for working with Microsoft Jet (.MDB) databases, you can access several ISAM databases and any database for which you have an ODBC driver, including remote databases such as Microsoft SQL Server or Oracle. For more information about these non-.MDB sources, see the article DAO External: Working with External Data Sources.
How MFC Exposes the Database Engine
In DAO, the database engine is represented by a DBEngine object. This object sits at the top of the DAO object hierarchy and contains all of the other objects, such as workspaces and databases. For detailed information about this DAO object, see the topic "DBEngine Object" in DAO Help. To view the DAO object hierarchy, see the topic "Data Access Object Hierarchy" in DAO Help.
In MFC, the DBEngine object is not exposed directly via an MFC class. Instead, all access to the underlying DAO database engine object is through a set of static member functions in class . These member functions provide access to database engine properties that you can set or get to configure your database sessions. You can access the database engine through any workspace object, whether MFC creates the object implicitly or you create it explicitly. In the majority of situations, you will not need to set these properties. You can rely on the defaults instead.
Database Engine Collections
DAO's DBEngine object houses two important collections used with MFC:
Workspaces
Errors
The DBEngine’s Workspaces Collection
The Workspaces collection contains all open DAO workspace objects that you have explicitly appended to the collection. See the article DAO Collections: Obtaining Information About DAO Objects for a discussion of how to use the Workspaces collection.
The DBEngine’s Errors Collection
The Errors collection contains one DAO error object for each error returned by the most recent DAO operation. In most error situations, particularly when you are working with a Microsoft Jet (.MDB) database, the collection contains one object. If you are using an ODBC data source, it is likely that the collection might contain more than one error object. In MFC, all DAO errors are translated into thrown exceptions of type . See class CDaoException and the article Exceptions: Database Exceptions for a discussion of how to work with MFC's DAO exceptions.
Initializing and Uninitializing the Database Engine
MFC loads a single instance of the DAO DBEngine object, housed in a DLL, per application. Thus your database engine sessions are limited to your application. Your workspaces are not available to other applications or users.
Initializing the Database Engine
MFC initializes the database engine, beginning your database engine session, the first time your application creates or opens a workspace, either implicitly or explicitly. For more information about explicit and implicit workspaces, see the article DAO Workspace.
Uninitializing the Database Engine
MFC uninitializes the database engine, ending your database engine session, when your application terminates.
See Also DAO: Where Is..., DAO Workspace, DAO Workspace: Accessing Properties of the Database Engine