Home | Overview | How Do I | FAQ | Sample | Tutorial | ODBC Driver List
This article explains the role of CDaoWorkspace objects in your application. For task-oriented information about using workspaces, see the article DAO Database: Using Workspaces and Databases. For an understanding of the DAO workspace object underlying each MFC CDaoWorkspace object, see the topic "Workspace Object" in DAO Help.
Topics covered include:
A DAO workspace, represented in MFC by class CDaoWorkspace, manages a session with the Microsoft Jet database engine. A workspace can contain one or more open DAO database objects, represented in your program, explicitly or implicitly, by CDaoDatabase objects. In DAO, workspaces manage a single transaction space in which any transaction applies to all open databases and recordsets. DAO workspaces also manage database security.
In MFC, workspaces are primarily transaction spaces; MFC does not expose DAO's security features, although you can program them yourself by directly calling DAO. For more information, see Technical Note 54.
In DAO, a separate DBEngine object manages the properties of the single instance of the Microsoft Jet database engine underlying multiple open workspaces. In MFC, access to the database engine's properties is through static member functions of class CDaoWorkspace. For more information, see the article DAO Workspace: The Database Engine.
In DAO:
In MFC, access to both the DBEngine's Workspaces collection and any workspace's Databases collection is through member functions of a CDaoWorkspace object. MFC doesn’t provides direct access to the Users collection or the Groups collection, which are part of DAO's security support; and MFC doesn’t expose DAO security features. For information about DAO collections in MFC, see the article DAO Collections.
In DAO, the first workspace in the Workspaces collection is called the default workspace. By default, if you open databases, they exist within the default workspace. In MFC, if you open a database object without specifying a workspace, or open a recordset object without specifying a database object, MFC implicitly uses DAO's underlying default workspace to manage transactions.
You seldom have to explicitly create a CDaoWorkspace object, but you can create explicit CDaoWorkspace objects if you need an explicit object for any of the activities described in Workspace Roles.
For information about workspaces in DAO, see the topic "Workspace Object" in DAO Help. For more information about workspaces in MFC, see the rest of this article and the article DAO Database: Using Workspaces and Databases.
CDaoWorkspace provides the following:
MFC implicitly creates a CDaoWorkspace object, and its underlying DAO workspace, when you:
See the article DAO: Accessing Implicit MFC DAO Objects for information on accessing:
Workspaces exist in memory for the life of a database engine session. When that session terminates, the default workspace, the Workspaces collection, and the Databases collections of any workspaces cease to exist (the actual databases do persist). These software objects are not stored on disk or in a database. When you begin a new database engine session and want to use the workspaces and databases you used in the last session, you must re-create any explicit workspace objects you need and reopen any databases you want associated with a workspace.
Tip Use a Windows registry entry to preserve a record of the workspaces and databases you had open during a database engine session.
For more information about workspaces in MFC see the following articles (in the recommended order):
See Also DAO: Where Is..., DAO Database: Using Workspaces and Databases, DAO Workspace: The Database Engine, DAO Database, DAO: Creating, Opening, and Closing DAO Objects