CdbWorkspace::OpenDatabase Method

Opens a specified database in a CdbWorkspace object.

Syntax

CdbDatabaseOpenDatabase(LPCTSTR pstrName,

BOOL bExclusive=FALSE,

BOOL bReadOnly=FALSE,

LPCTSTR pstrConnect=NULL);

Parameters

Type Example Description
LPCTSTR pstrName A pointer to a 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 Optional. A Boolean.

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 that specifies various connection information, including passwords.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbWorkspace      ws;
CdbDatabase      db;
...               // Initialize ws, etc.
               // Open database in shared, read/write mode, no 
               // connect information.
db = ws.OpenDatabase(_T("db1.mdb"));