4,011
社区成员
发帖
与我相关
我的任务
分享
//打印调用ADO控件时产生的详细错误信息
void dump_com_error(_com_error &e)
{
CString ErrorStr;
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
ErrorStr.Format( "\n\tADO Error\n\tCode = %08lx\n\tCode meaning = %s\n\tSource = %s\n\tDescription = %s\n\n",
e.Error(), e.ErrorMessage(), (LPCTSTR)bstrSource, (LPCTSTR)bstrDescription );
//在调试窗口中打印错误信息,在Release版中可用DBGView查看错误信息
::OutputDebugString((LPCTSTR)ErrorStr);
#ifdef _DEBUG
AfxMessageBox(ErrorStr, MB_OK | MB_ICONERROR);
#endif
}
try
{
//你的ADO代码
}
catch(_com_error& e)
{
dump_com_error(e);
}
//打印调用ADO控件时产生的详细错误信息
void dump_com_error(_com_error &e)
{
CString ErrorStr;
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
ErrorStr.Format( "\n\tADO Error\n\tCode = %08lx\n\tCode meaning = %s\n\tSource = %s\n\tDescription = %s\n\n",
e.Error(), e.ErrorMessage(), (LPCTSTR)bstrSource, (LPCTSTR)bstrDescription );
//在调试窗口中打印错误信息,在Release版中可用DBGView查看错误信息
::OutputDebugString((LPCTSTR)ErrorStr);
#ifdef _DEBUG
AfxMessageBox(ErrorStr, MB_OK | MB_ICONERROR);
#endif
}
UpdateData(FALSE);
CString strSql(_T("Select * from "));
strSql += m_edit;
if (m_pRecordset != NULL)
{
m_pRecordset->Close();
}
m_pRecordset->Open(strSql,.....)