怎么捕捉错误?
linyk 2004-02-26 10:40:34 VC, ADO, Access.
Date & Person & Event共同作主键。使用下面语句时catch好像抓不到错。
- 添加新记录程序可以正确执行
- 添加已有记录时由于主键冲突,我希望能住到错误信息,但好像这样抓不到,程序报错"this application has requested the runtime...".
try
{
m_pRecordset->AddNew();
m_pRecordset->PutCollect("Date",_variant_t(m_sDate));
m_pRecordset->PutCollect("Person",_variant_t(m_sPerson));
m_pRecordset->PutCollect("Event",_variant_t(m_sEvent));
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
谢谢!