Dll中连接ACCESS数据库
在Dll写连接数据库的语句,编译正确
#pragma warning(disable:4146)
#import "C:/Program Files/Common Files/System/ADO/msado15.dll" named_guids rename("EOF","adoEOF"), rename("BOF","adoBOF")
#pragma warning(default:4146)
using namespace ADODB;
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
AfxOleInit();
m_pConnection.CreateInstance(__uuidof(Connection));
try
{
// 打开本地Access库Demo.mdb
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Db1.mdb","","",adModeUnknown);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
运行调用dll的exe报错
Debug error!
Program: ...式\dll\regulardllCall\Debug\regulardllCall.exe
abnormal program termination
(Press Retry to debug the application)
在源代码中调试报错
Unhandled exception in regulardllCall.exe (KERNEL32.DLL):0xE06D7363:Microsoft C++ Exception.