CDatabaseConnection::ConnectToDatabase
The ConnectToDatabase method creates a workspace and opens a connection to the Guide database. C syntax is shown.
BOOL ConnectToDatabase(
const CString &csViewer,
const CString &csPassword,
const CString &systemFile,
const CString &databaseFile,
CString csWorkspaceName
);
Parameters
- csViewer
- Reference to a CString object that contains the name of the current user. The CString object is part of Microsoft® Foundation Classes (MFC). Loader applications should use "Loader" for the csViewer parameter value. Logging on as "Loader" ensures that a loader has read/write permissions for the database.
- csPassword
- Reference to an MFC CString object that contains the password of the user specified in csViewer. This string is not changed by the call to ConnectToDatabase.
- systemFile
- Reference to an MFC CString object that contains the full path and file name of the workgroup information file.
- databaseFile
- Reference to an MFC CString object that specifies the path and name of the database file. This string is not changed by the call to ConnectToDatabase.
- csWorkspaceName
- Reference to an MFC CString object containing the name of the open workspace. To get this information, your application calls the GetWorkspaceName method after ConnectToDatabase returns. Loaders can use any workspace name for the csWorkspaceName parameter, but "LoaderWSP" is recommended.
Return Values
Returns TRUE if the database was successfully opened, and FALSE otherwise.
Remarks
The ConnectToDatabase method calls the CDatabaseConnection::StartEngine method automatically if the Jet database engine hasn't already been started. However, if your application needs to use engine functionality such as compacting or repairs without opening the database, it can call StartEngine explicitly.
Windows NT/2000: Unsupported.
Windows 95/98: Requires Windows 98.
Header: Declared in dbsets.h.
Import Library: Use dbsets.lib or dbsetsst.lib.
See Also
CDatabaseConnection::StartEngine, GetWorkspaceName, SetJet