.NET
Microsoft Technologies based on the .NET software framework.
3,801 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am running a small program in x64 mode (Visual Studio 2019) for opening a database :
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
#include "icrsint.h"
_COM_SMARTPTR_TYPEDEF(IADORecordBinding, __uuidof(IADORecordBinding));
_ConnectionPtr m_pConnectionPtr = 0;
int main()
{
HRESULT hr = CoInitialize(NULL);
m_pConnectionPtr = NULL;
m_pConnectionPtr.CreateInstance(__uuidof(Connection));
bstr_t strCnn(R"(Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=c:\myDatabase.accdb;User ID=sa;)");
m_pConnectionPtr->Open(strCnn, "", "", NULL);
m_pConnectionPtr->Close();
}
Running this an exception is thrown in msado15.tli :
This exception messes with my stack.
When doing this x86 I do not have this exception.
This works for me with ACE Driver, in x86 or x64, in Unicode (remove the password for your accdb file... ) :
{
_ConnectionPtr m_pConnectionPtr = 0;
HRESULT hr = CoInitialize(NULL);
m_pConnectionPtr = NULL;
m_pConnectionPtr.CreateInstance(__uuidof(Connection));
_bstr_t strCnn("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\employees.accdb;Jet OLEDB:Database Password=toto;");
m_pConnectionPtr->Open(strCnn, L"", L"", NULL);
m_pConnectionPtr->Close();
}