This example forces an error, traps it, and displays the Description, Number, and Source properties of the resulting Error object.
CdbDBEngine dbeng;
CdbDatabase db;
try
{
db = dbeng.OpenDatabase(_T("DoesNotExist"));
}
catch (CdbException e)
{
CdbError err;
CString stErr, stErr2;
for (int iErr = 0;
iErr < dbeng.Errors.GetCount();
iErr++)
{
err = dbeng.Errors[iErr];
stErr.Format(_T("%ld"), DBERR(err.GetNumber()));
stErr += _T(" : ");
stErr2.Format(_T("%s"), err.GetDescription());
stErr += stErr2 + _T(" : ");
stErr2.Format(_T("%s"), err.GetSource());
stErr += stErr2 + _T("\n");
}
MessageBox(NULL, stErr, _T("ForceError"), MB_OK);
}