Share via


DAO Workspace

OverviewHow Do IFAQSampleODBC Driver List

This article explains the role of 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:

  • Workspace: definition

  • MFC workspaces are transaction spaces

  • Database engine access

  • Workspace collections

  • Default workspace

  • Workspace roles

  • Accessing workspace objects

  • Workspace persistence

  • Further reading about workspaces

Workspace: Definition

A DAO workspace, represented in MFC by class , 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 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.

Transaction Spaces

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 .

Database Engine Access

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 . For more information, see the article DAO Workspace: The Database Engine.

Workspace Collections

In DAO:

  • The DBEngine object contains a "collection" of open workspace objects, called the Workspaces collection.

  • Each DAO workspace object in turn contains collections of open databases, active users, and active user groups.

In MFC, access to both the DBEngine's Workspaces collection and any workspace's Databases collection is through member functions of a 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.

Default Workspace

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 object, but you can create explicit CDaoWorkspace objects if you need an explicit object for any of the activities described in Workspace Roles.

Information About Workspaces in DAO Help

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.

Workspace Roles

provides the following:

  • Explicit access to DAO's default workspace.

  • Access to the Workspaces collection or the default workspace's Databases collection.

  • A separate transaction space if you need to separate the transactions on one database from those on another database.

  • Access to the properties of the database engine.

Accessing Workspace Objects

MFC implicitly creates a object, and its underlying DAO workspace, when you:

  • Construct a object without specifying the workspace.

  • Construct a object without specifying the database.

See the article DAO: Accessing Implicit MFC DAO Objects for information on accessing:

  • The CDaoWorkspace object associated with a CDaoDatabase object

  • The CDaoWorkspace object associated with the CDaoDatabase object associated with a CDaoRecordset object

Workspace Persistence

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.

Further Reading About Workspaces

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