In dbDAO, the CdbDBEngine class initializes the DAO DBEngine object. (As noted earlier in this chapter, declaring a variable of class CdbDBEngine is not done in Visual Basic). CdbDBEngine has two constructors:
void CdbDBEngine::CdbDBEngine(BOOL bPrivate=FALSE, BOOL bStart=TRUE, LPCTSTR pstrIniPath=NULL, LPCTSTR pstrDefUser=NULL, LPCTSTR pstrDefPW=NULL, LONG lType=dbUseJet) void CdbDBEngine::CdbDBEngine(DAODBEngine *peng, BOOL bAddRef=FALSE)
The first constructor allows you to specify the whether the DBEngine object is private or shared, whether the engine should start on construction, the IniPath, the default user, the default password, and the default type for workspaces. Once the engine is started, these properties cannot be modified. The second constructor allows you to add an additional reference to an existing instance of the DBEngine object. Both constructors call CoCreateInstance to create an instance of the DBEngine object and obtain a DAODBEngine interface pointer (the underlying Automation interface as defined in Dbdaoint.h).
Each private engine is a new instance of DAO. A shared engine is common across all instances, enabling them to share open workspaces, databases, recordsets, and so on.
If you don’t start the engine on construction, you can use a Start method to start it. Before invoking the Start method, you can override the default registry key by setting the IniPath property and override the default workgroup information file by setting the SystemDB property.