locked
Accessing 32 bit access Database from 64 bit application. RRS feed

  • Question

  • Hi All.

    I am developing and sample 64 bit application , I need to perform db operation with Microsoft access db which is 32 bit.

    But I am getting error in open()

    Here is the connection methods I am using.


    GetModuleFileName(NULL, szSysDir, MAX_PATH);
    *strrchr(szSysDir,'\\') = 0;

    strDBSrc = (CString)szSysDir + "\\abc.cwk";

    sConnectionStr.Format("Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Pwd=password;", strDBSrc);

    Thanks in Advance any solution or suggestions.

    Tuesday, July 7, 2020 1:28 PM

All replies


  • But I am getting error in open()

    Which error ?

    Have you installed the  32-bit Microsoft Access Database Engine ?

    This works for me with DAO, x64 on Windows 10, to open a .mdb =>

    _DBEngine *pDBEngine = NULL;
    HRESULT hr = CoCreateInstance(__uuidof(DAO::DBEngine), NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (LPVOID*)&pDBEngine);
    if (SUCCEEDED(hr) && pDBEngine)
    {
    	try
    	{
    		_bstr_t bstrDatabase = L"E:\\Employees.mdb";
    		WCHAR wsConnect[32] = L"";
    		wsprintf(wsConnect, L";pwd=%s", L"toto");						
    		DAO::DatabasePtr pDb = pDBEngine->OpenDatabase(bstrDatabase, _variant_t(1), _variant_t(0), _variant_t(wsConnect));
    		//...
    		pDb->Close();
    	}
    	catch (_com_error &e)
    	{
    		_bstr_t bstrSource(e.Source());
    		_bstr_t bstrDescription(e.Description());
    		WCHAR wsBuffer[255];
    		wsprintf(wsBuffer, L"Source : %s\nDescription : %s", (LPCTSTR)bstrSource, (LPCTSTR)bstrDescription);
    		MessageBox(NULL, wsBuffer, L"Error", MB_OK | MB_ICONSTOP);
    	}
    }

    Tuesday, July 7, 2020 2:03 PM
  • Have you solved the problem?

    Access databases are neither 32-bit nor 64-bit. The drivers (that are executed to access the data) are but the format of the data stored on disk is the same.



    Sam Hobbs
    SimpleSamples.Info

    Wednesday, July 15, 2020 8:47 PM