Creates an instance of the Microsoft 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);
(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 DAO Automation interface pointer corresponding to this DAO class. |
BOOL | bAddRef =FALSE |
Optional. A Boolean. If TRUE, the DAO Automation interface AddRef function is called. |
DAO functionality is presented through pointers to DAO Automation interfaces. This constructor makes a DAO interface available in the form of a DAO class object that provides additional functionality.
This constructor is not required for typical use. It is provided to allow easy creation of a DAO class object for those with access to the corresponding DAO interface.
When the destructor for the DAO object is invoked, the underlying Automation interface's Release member is called. If Release decrements the interface's reference count to zero, the pointer to the Automation interface can be deleted. If you don't want this to happen (for example, because you want to discard the DAO object but continue using the Automation interface), specify TRUE for the second parameter. The underlying Automation interface's AddRef member is called, which counterbalances the eventual call to Release.
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 the Microsoft 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 and databases, for example. If TRUE, then private. |
BOOL | bStart=TRUE | Optional. A Boolean. TRUEThe Microsoft Jet engine is started when this object is created. FALSEThe Microsoft 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 Microsoft Jet or ODBC (that is, dbUseJet or dbUseODBC). |
This constructor creates an instance of the CdbDBEngine class.
This constructor is typically specified without parameters (that is, using all defaults) which makes it look like other DAO object constructors that take no parameters.
One reason to specify parameters is to create the Microsoft Jet Database Engine but postpone starting it. This enables you to acquire run-time information, or avoid run-time conflicts when starting DAO from a user DLL. Another common reason to specify parameters is to create an ODBCDirect workspace.
Usage
#include <afxole.h>
#include <dbdao.h>
// Example 1:
CdbDBEngine dben1a; // Create an instance using defaults.
CdbDBEngine dben1b( dben1a ); // Copy an existing instance.
// Example 2:
/* Create an instance of CdbDBEngine without using defaults.
Specify: a private engine; don't start it when constructed; no IniPath, DefaultUser, or password, yet; explicitly request a Microsoft Jet workspace.
*/
CdbDBEngine dben2(TRUE,FALSE,NULL,NULL,NULL,dbUseJet);
// After getting IniPath, DefaultUser, and DefaultPassword from the // user, set the CdbDBEngine object with those values.
dben2.SetIniPath(lpctstrIniPath);
dben2.SetDefaultUser(lpstrDefaultUser);
dben2.SetDefaultPassword(lpctstrPassword);
// Now, start the engine.
dben2.Start();