现在是用VC操作Access数据库,m_pRecordset代表_RecordsetPtr;id,name,sex为CString型;现在的问题是如果这三个变量中有空值就会抛异常,怎么在异常处理中得知是哪句抛的异常??
try{
m_pRecordset->AddNew();
m_pRecordset->PutCollect("bianhao",_variant_t(id));
m_pRecordset->PutCollect("mingcheng",_variant_t(name));
m_pRecordset->PutCollect("sex",_variant_t(sex));
m_pRecordset->Update();
}
catch (_com_error &e) {
HRESULT hr=e.Error();
CString eStr;
eStr.Format("The Error Code:%08lx ,The Error Message:%s,The source:%s,The Desp:%ld",hr,e.ErrorMessage(),(LPCTSTR)e.Source(),e.Description());
AfxMessageBox(eStr);
return false;
}
try{
m_pRecordset->AddNew();
m_pRecordset->PutCollect("bianhao",_variant_t(id));
m_pRecordset->PutCollect("mingcheng",_variant_t(name));
m_pRecordset->PutCollect("sex",_variant_t(sex));
m_pRecordset->Update();
}
catch (_com_error &e) {
HRESULT hr=e.Error();
CString eStr;
eStr.Format("The Error Code:%08lx ,The Error Message:%s,The source:%s,The Desp:%ld",hr,e.ErrorMessage(),(LPCTSTR)e.Source(),e.Description());
AfxMessageBox(eStr);
return false;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货