//Access2000 database and DAO To read Access 2000mdb, i added the following code : AfxGetModuleState()->m_dwVersion = 0x0601; and then i could read Access 2000 mdb, Your project config must be set to shared dll Insert into the initinstance of your myprojapp.h file as shown below [ccode] #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL AfxGetModuleState()->m_dwVersion = 0x0601; #else Enable3dControlsStatic(); // Call this when linking to MFC statically' #endif [/ccode] Hope that helps Submitted By: gatman (2001/06/08)
m_pConnection->ConnectionTimeout = 60;
m_pConnection->Mode = adModeReadWrite; CString strConnection(_T("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="));
TCHAR buf[100];
ZeroMemory(buf, sizeof(buf)/sizeof(TCHAR));
::GetModuleFileName((HMODULE)AfxGetInstanceHandle(), buf, sizeof(buf)/sizeof(TCHAR));
CString strPath = buf;
int n = strPath.GetLength();
TCHAR cName[] = TEXT("CompanyData.exe");
strPath.Delete(n-sizeof(cName)/sizeof(TCHAR) +1, sizeof(cName)/sizeof(TCHAR));
strPath = strPath + '\\' + "company.mdb";
strConnection += strPath;
m_strCon = strConnection; try
{
m_pConnection->ConnectionString = _bstr_t(strConnection);
m_pConnection->Open( "", "", "", -1); }
catch ( _com_error &e )
{
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ")
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ")
+ _bstr_t(e.Description());
MessageBox(NULL, bs, bstrSource, MB_OK);
return FALSE;
}
To read Access 2000mdb, i added the following code :
AfxGetModuleState()->m_dwVersion = 0x0601;
and then i could read Access 2000 mdb,
Your project config must be set to shared dll
Insert into the initinstance of your myprojapp.h file as
shown below
[ccode]
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
AfxGetModuleState()->m_dwVersion = 0x0601;
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically'
#endif
[/ccode]
Hope that helps
Submitted By: gatman (2001/06/08)