_bstr_t str1 ("select * from pacs.table1");
pRs1 = pConnection->Execute(str1,NULL,adOptionUnspecified);
我这句话有问题么?我的pConnection已经打开,str1可以在SQL Plus里面执行,但是为什么在程序里报了IDispatch的错误?
pRs1 = pConnection->Execute(str1,NULL,adOptionUnspecified);
我这句话有问题么?我的pConnection已经打开,str1可以在SQL Plus里面执行,但是为什么在程序里报了IDispatch的错误?
try
{
// do your sql function;;
}
catch(_com_error * e)
{
MessageBox(NULL,"",e->ErrorMessage(),MB_OK);
}
catch(...)
{
long errorcount=m_pConnection->GetErrors ()->GetCount ();
char add[255];
strcpy(add,"");
for (short i=0;i<errorcount;i++)
{
strcat(add,m_pConnection->GetErrors ()->GetItem (_variant_t((short)i))->GetDescription ());
}
printf(add);
}
捕捉到的是_com_error的错误
那几句源程序实在看不出来有什么错,麻烦再多贴点。
谢谢了
pRs = m_pAppointConnection->Execute(str,NULL,adOptionUnspecified);
pRs->Open("select PACS.DFHH from PACS.TABLE1",m_pAppointConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);
}
catch (_com_error& e) {
CString errormessage;
AfxMessageBox("操作错误");
MessageBox(e.ErrorMessage());
errormessage.Format("数据库操作!\r\n错误信息:%s",e.ErrorMessage());
errorfile.WriteError(errormessage);
PostQuitMessage(0);
return FALSE;
}
加上L
_bstr_t str1 (L"select * from pacs.table1");
这样就行了,不用再pRs->Open("select PACS.DFHH from PACS.TABLE1",m_pAppointConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);否则就需要先加pRs->Close();
同时也多谢 ZHENG017() 大力支持