备份SQL2000数据库出错

bnm77 2012-11-13 05:30:22

在按钮上加入
m_pRecordset = m_pConnection->
Execute ( "backup database xyz to disk= 'C:\bak.bak' with init",NULL,adCmdText);
。点击后可以进行备份,但备份之后1分钟出错,显示unhandled.....。何故?
...全文
100 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zyq5945 2012-11-14
  • 打赏
  • 举报
回复
m_pRecordset是NULL值的时候m_pRecordset->调用肯定是有错误的。 加异常捕获看是什么错误
try
{
//你的ADO代码
}
catch (_com_error& e)
{
CString strMsg;
strMsg.Format(_T("错误描述:%s\n错误消息%s"), 
		(LPCTSTR)e.Description(),
		(LPCTSTR)e.ErrorMessage());
AfxMessageBox(strMsg);
}


catch(CException* pEx)
{
pEx->ReportError();
pEx->Delete();
}
bnm77 2012-11-14
  • 打赏
  • 举报
回复
用过这条语句之后,后面只要遇到m_pRecordset->就出错。
bnm77 2012-11-14
  • 打赏
  • 举报
回复
感觉好像是这条语句影响了其他语句的正常工作,譬如数据库的一些语句,数据库一直处于打开状态,中间插入这一语句之后,与后续的语句发生了冲突。
bnm77 2012-11-14
  • 打赏
  • 举报
回复
try{ //你的ADO代码 m_pRecordset = m_pConnection-> Execute ( "backup database xyz to disk= 'C:\bak.bak' with init",NULL,adCmdText); } catch (_com_error& e) { CString strMsg; strMsg.Format(_T("错误描述:%s\n错误消息%s"), (LPCTSTR)e.Description(), (LPCTSTR)e.ErrorMessage()); AfxMessageBox(strMsg); } 首先,在catch之后加断点,发现经过catch语句,但未进入陷阱。 具体提示为: Unhandled exception in xyz.exe (KERNEL32.DLL):0xE06D7363:Microsoft C++ ...
zyq5945 2012-11-14
  • 打赏
  • 举报
回复
try
{
//你的ADO代码
}
catch (_com_error& e)
{
CString strMsg;
strMsg.Format(_T("错误描述:%s\n错误消息%s"), 
        (LPCTSTR)e.Description(),
        (LPCTSTR)e.ErrorMessage());
AfxMessageBox(strMsg);
}
catch(CException* pEx)
{
pEx->ReportError();
pEx->Delete();
}
catch(const std::execption &stdEx)
{
AfxMessageBox(stdEx.what());
}
catch(...)
{
AfxMessageBox(_T("其他异常"));
}
bnm77 2012-11-14
  • 打赏
  • 举报
回复
引用 5 楼 zyq5945 的回复:
m_pRecordset是NULL值的时候m_pRecordset->调用肯定是有错误的。 加异常捕获看是什么错误 C/C++ code? 12345678910111213141516171819 try{ //你的ADO代码 } catch (_com_error& e) { CString strMsg; strMsg.Format(_T("错误描述:……
未进入两个catch{} 之内。
zyq5945 2012-11-13
  • 打赏
  • 举报
回复
加异常捕获看是什么错误
try
{
//你的ADO代码
}
catch (_com_error& e)
{
CString strMsg;
strMsg.Format(_T("错误描述:%s\n错误消息%s"), 
		(LPCTSTR)e.Description(),
		(LPCTSTR)e.ErrorMessage());
AfxMessageBox(strMsg);
}

4,011

社区成员

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

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