Workspace Objects

There are two types of Workspace objects: Microsoft Jet Workspace objects and ODBCDirect Workspace objects. This section discusses Microsoft Jet Workspace objects. For information about ODBCDirect Workspace objects, see Chapter 9, “Developing Client/Server Applications.”

A Workspace object exists for each active session of the Jet database engine. A session delineates a sequence of operations performed by Microsoft Jet. A session begins when a user logs on and ends when the user logs off. All operations during a session are subject to permissions determined by the logon user name and password. The Workspaces collection contains all Workspace objects defined by the currently running instance of DAO.

The ability to create multiple workspaces in code is useful when you have to log on to Microsoft Jet as another user. Also, because each Workspace object maintains its transactions independent of other workspaces, managing multiple workspaces can be useful when you have to manage multiple sets of independent transactions.

When you start DAO, what happens with workspaces depends on whether or not you have security established. If you don’t have security established, DAO automatically creates the default Workspace object. The settings of the Name and UserName properties of the default Workspace object are #Default Workspace# and Admin, respectively.

If you want to use security, you can set the SystemDB property to the current location of the workgroup information file (System.mdw), set the DefaultUserName property, and set the DefaultPassword property. When you use the OpenDatabase method without specifying a Workspace object, a default Workspace object is created by using these defaults.