Opens a specified database in a Workspace object and returns a reference to the Database object that represents it.
Syntax
CdbDatabaseOpenDatabase(LPCTSTR pstrName,
BOOL bExclusive=FALSE,
BOOL bReadOnly=FALSE,
LPCTSTR pstrConnect=NULL);
Parameters
Type | Example | Description |
LPCTSTR | pstrName | A pointer to string that is the name of an existing Microsoft Jet database file, or the data source name (DSN) of an ODBC data source. See the Name property for more information about setting this value. |
BOOL | bExclusive | A Boolean. For Microsoft Jet workspaces only: TRUEOpens the database in exclusive mode. FALSE(Default) opens the database in shared mode. |
BOOL | bReadOnly | Optional. A Boolean. TRUEOpens the database with read-only access. FALSE(Default) Opens the database with read/write access. |
LPCTSTR | pstrConnect | Optional. A pointer to a string composed of a database type specifier and zero or more parameters separated by semicolons. This parameter passes additional information to ODBC and certain ISAM drivers as needed. |
Usage
#include <afxole.h>
#include <dbdao.h>
CdbDBEngine dben;
CdbDatabase db;
// Open a local Jet database in exclusive, read/write mode.
db = dben.OpenDatabase(_T("C:\\YourJetDB.mdb"), TRUE);