我正在使用ado将我的c ++项目连接到数据库。因此,当我建立与SQL Server的连接并比打开连接时,会遇到找不到comutil.cpp的错误,但只有在调试过程中使用step into(F11)
时,如果使用step over(F10)
时,没有错误,然后继续运行。
我已经搜索过计算机,但无法在任何地方找到该文件。 我应该安装comutil.cpp源代码还是文件?
p.s在连接执行之前,我没有错误。(错误是:DB_E_ERRORSOCCURRED Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
)也可以在连接打开时得到,但它也不会得到任何值<Information not available, no symbols loaded for msado15.dll>
,这与comutil.cpp有关吗?如果没有,我该如何执行连接?
我一直在努力寻找解决办法,但是没人知道如何解决这个问题吗?
//TESTHR Function which check if HRESULT is okay or not
_ConnectionPtr pConnection;
_RecordsetPtr pRecordset;
_CommandPtr pCommand;
TESTHR(CoInitialize(NULL));
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
_bstr_t strCon(_T("ADOSQL"));
TESTHR(pConnection->Open(strCon, "", "", adOpenForwardOnly));
TESTHR(hr = pCommand.CreateInstance(__uuidof(Command)));
_bstr_t InsertQuery(_T("Insert Into TestTB(AccountID, Balance) Values(@AccountID, @Balance)"));
pCommand->ActiveConnection = pConnection;
pCommand->CommandText = InsertQuery;
pCommand->CommandType = adCmdText;
TESTHR(pRecordset.CreateInstance(__uuidof(Recordset)));
hr = pRecordset->Open(SQLQuery, pConnection.GetInterfacePtr(), adOpenForwardOnly, adLockReadOnly, adCmdText);
//-------------
//some operations
//-------------
pConnection->Execute(InsertQuery, vRecordsAffected, adCmdText); //here error occures
pRecordset->Close();
pConnection->Close();
CoUninitialize();