Share via


DAO Workspace: Explicitly Opening the Default Workspace

OverviewHow Do IFAQSampleODBC Driver List

Normally you don't need to refer explicitly to DAO's default workspace. MFC uses it automatically when you open new databases, recordsets, tabledefs, and querydefs. But sometimes you need explicit access to the default workspace — for example, to access the Workspaces collection or to set database engine properties. For that kind of access, you might need a object.

The Most Likely Case

The most likely case is that you already have a object or a object based on the default workspace (or on an additional workspace). For those cases, see the article DAO: Accessing Implicit MFC DAO Objects. Otherwise, if you don't have a database or recordset object handy, you can still open the default workspace as follows:

To explicitly open the default workspace

  1. Construct a object.

  2. Call the object's member function. Specify NULL for the lpszName parameter.

  3. Call other member functions or access data members.

Closing this CDaoWorkspace object has no effect on DAO's default workspace. That workspace is terminated when the database engine session terminates. For information on database engine termination, see the article DAO Workspace: The Database Engine.

See Also   DAO: Where Is..., DAO: Accessing Implicit MFC DAO Objects, DAO Workspace, DAO: Creating, Opening, and Closing DAO Objects