熟悉ADO和ORACLE的朋友帮忙啊,急急急急!!!!1

Michael_Zhang 2002-12-13 03:54:41
_bstr_t str1 ("select * from pacs.table1");
pRs1 = pConnection->Execute(str1,NULL,adOptionUnspecified);
我这句话有问题么?我的pConnection已经打开,str1可以在SQL Plus里面执行,但是为什么在程序里报了IDispatch的错误?

...全文
31 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Michael_Zhang 2002-12-16
  • 打赏
  • 举报
回复

哦,好,散分
ZHENG017 2002-12-16
  • 打赏
  • 举报
回复
L哈,就是让后面的内容变成宽字符,就ascii->unicode.
Michael_Zhang 2002-12-16
  • 打赏
  • 举报
回复


好好,多谢nustchenhf() 就是因为这个L,我想问一下这个L是做啥用的?
同时也多谢 ZHENG017() 大力支持
ZHENG017 2002-12-15
  • 打赏
  • 举报
回复
pRs = m_pAppointConnection->Execute(str,NULL,adOptionUnspecified);
这样就行了,不用再pRs->Open("select PACS.DFHH from PACS.TABLE1",m_pAppointConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);否则就需要先加pRs->Close();
nustchenhf 2002-12-13
  • 打赏
  • 举报
回复
_bstr_t str1 ("select * from pacs.table1");
加上L
_bstr_t str1 (L"select * from pacs.table1");
Michael_Zhang 2002-12-13
  • 打赏
  • 举报
回复
try{
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;
}
Michael_Zhang 2002-12-13
  • 打赏
  • 举报
回复
IDispatch error #3092
谢谢了
ZHENG017 2002-12-13
  • 打赏
  • 举报
回复
HI,把_com_error的错误paste出来哈。
那几句源程序实在看不出来有什么错,麻烦再多贴点。
Michael_Zhang 2002-12-13
  • 打赏
  • 举报
回复

捕捉到的是_com_error的错误
ZHENG017 2002-12-13
  • 打赏
  • 举报
回复
//先看看错误提示是什么:
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);
}

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧