Function
Create an instance of the Jet Database Engine.
Syntax Summary
CONSTRUCTORCdbDBEngine(const CdbDBEngine &);
CONSTRUCTORCdbDBEngine(DAODBEngine *peng,
BOOL bAddRef=FALSE);
CONSTRUCTORCdbDBEngine(BOOL bPrivate=FALSE,
BOOL bStart=TRUE,
LPCTSTR pstrIniPath=NULL,
LPCTSTR pstrDefUser=NULL,
LPCTSTR pstrDefPW=NULL,
LONG lType=dbUseJet);
Note The qualifier 'CONSTRUCTOR' is merely a decoration provided to help readability. It has no syntactic value.
Syntax / Parameters / Remarks
CONSTRUCTORCdbDBEngine(const CdbDBEngine &);
Type | Description | |
const CdbDBEngine & | Reference to an object. |
This constructor creates a copy of the object referenced in the parameter.
Syntax / Parameters / Remarks
CONSTRUCTORCdbDBEngine(DAODBEngine *peng,
BOOL bAddRef=FALSE);
Type | example | Description |
DAODBEngine * | peng | A pointer to an OLE interface whose methods correspond to the resulting DAO class object. |
BOOL | bAddRef =FALSE |
(Optional) A boolean. If TRUE, the AddRef() function of the OLE interface specified in the first parameter is called. |
This constructor places an OLE interface into a DAO object.
Syntax / Parameters / Remarks
CONSTRUCTORCdbDBEngine(BOOL bPrivate=FALSE,
BOOL bStart=TRUE,
LPCTSTR pstrIniPath=NULL,
LPCTSTR pstrDefUser=NULL,
LPCTSTR pstrDefPW=NULL,
LONG lType=dbUseJet);
Type | example | Description |
BOOL | bPrivate =FALSE |
(Optional) Determines whether Jet Engine is Private or Shared. Each private engine is a new instance of DAO. A Private engine is one way to create secure access to data. A shared engine is common across all instances, enabling shared workspaces, databases, etc. If TRUE, then Private. |
BOOL | bStart=TRUE | (Optional) If TRUE, Jet Engine is started when this object is created. If FALSE, the Jet Engine must be started explicitly with the Start method. |
LPCTSTR | pstrIniPath =NULL |
(Optional) A pointer to a string that is a user-supplied portion of the Windows Registry key containing Microsoft Jet database engine settings or parameters needed for installable ISAM databases. |
LPCTSTR | pstrDefUser =NULL | (Optional) A pointer to a string that is the user name used to create the default Workspace when it is initialized. |
LPCTSTR | pstrDefPW =NULL | (Optional) A pointer to a string that is the password used to create the default Workspace when it is initialized. |
LONG | lType=dbUseJet | (Optional) A value that determines whether the Workspace will be Jet or ODBC (i.e., dbUseJet or dbUseODBC). |
This constructor builds a CdbDBEngine object.
This constructor is typically specified without parameters (i.e., using all defaults).
One reason to specify parameters is to create the Jet Database Engine, but postpone starting it. This enables acquiring runtime information, or avoiding runtime conflicts when starting DAO from a user DLL. Another common reason to specify parameters is to create an ODBC Direct workspace.
Usage
#include <afxole.h>
#include <dbdao.h>
... // Example 1:
CdbDBEngine dben1a; // Create an instance using all defaults.
CdbDBEngine dben1b( dben1a ); // Copy an existing instance.
...
// Example 2:
// Create an instance without using all defaults:
// Create a private engine; don't start it when constructed; no IniPath, yet; // no DefaultUser; no password, yet; explicitly ask for a Jet Engine workspace.
CdbDBEngine dben2(TRUE,FALSE,,,,dbUseJet);
...
// Assume that you get the iniPath and DefaultPassword from the user...
dben2.SetIniPath(lpctstrIniPath); // Set the iniPath now.
dben2.SetDefaultPassword(lpctstrPassword); // Set the DefaultPassword now.
dben2.Start(); // Start the engine now.