MFC ado链接oracle数据库问题

Q446512799 2012-01-16 04:02:14
下面是查询的代码,帮忙看看有什么问题
新人求指导

COracle_messageApp theApp;
int i=0;
theApp.m_pConnection->Execute((_bstr_t)sql,NULL,adCmdText);
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->Open("select*from myhome;",theApp.m_pConnection.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
try
{
if(!m_pRecordset->BOF)
m_pRecordset->MoveFirst();
else
{
AfxMessageBox("表内数据为空");
return;
}
}
catch(_com_error e)//捕捉异常
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
CString sError;
sError.Format("Source:%s \n Description : %s\n",(LPCSTR)bstrSource,(LPCSTR)bstrDescription);
AfxMessageBox(sError);
return;
}

while (!(m_pRecordset->BOF)) //如果记录集不空
{
m_list.InsertItem(i,(LPTSTR)(_bstr_t)(m_pRecordset->GetCollect("id")));
// m_list.SetItemText(i,1,(LPTSTR)(_bstr_t)(pRs->GetCollect(_T("name"))));
// m_list.SetItemText(i,2,(LPTSTR)(_bstr_t)(pRs->GetCollect(_T("job"))));
// m_list.SetItemText(i,3,(LPTSTR)(_bstr_t)(pRs->GetCollect(_T("score"))));
m_pRecordset->MoveNext();
i++;
}

}
...全文
104 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fly4free 2012-01-19
  • 打赏
  • 举报
回复
晕,你有什么异常
倒是说说啊。
向立天 2012-01-16
  • 打赏
  • 举报
回复
你现在出了什么问题
一步一步的调试定位
再就是调试的时候把中间产生的sql语句考出来在oracle里测试一下
看看语句是否正确
康斯坦汀 2012-01-16
  • 打赏
  • 举报
回复
单步,如果发生异常查看异常信息,执行的SQL语句在管理器或者其他查询器里面执行验证一下。
oyljerry 2012-01-16
  • 打赏
  • 举报
回复
主要就是最终完整的sql语句是否正确

4,012

社区成员

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

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