Using ODBC CRecordset in an application.
While debugging my application I tried using a try/catch block but the application throws an exception while updating a record set at this point (the MFC file : dbcore.cpp line 3579 ) and terminates before my catch statement.
ThrowDBException((RETCODE)(lRowsAffected == 0 ?AFX_SQL_ERROR_NO_ROWS_AFFECTED :AFX_SQL_ERROR_MULTIPLE_ROWS_AFFECTED));
Inspecting the value of lRowsAffected I find it is == 0.
This is the block of code that is used to update.
for (int a=0;a<arsize;a++)
// CustAccounts.SetAbsolutePosition( a+1);
tempStorage = AccountList.GetAt(a);
//note: change struct var from type bool to char (BYTE)
if( tempStorage.UseAct == true)
use = '1';
use = '0';
if ( CustAccounts.m_bStatement != use)
CustAccounts.m_bStatement = use;
catch(CDBException * e)
CString errmsg = "The exception thrown :" + e->m_strError;
AfxMessageBox( errmsg, MB_ICONSTOP );
Why doesn't my catch statement handle the exception rather than just the program terminating?
I have 6 data sets and the application works on all but 1 of them (which throws the exception).
I would like to retrieve more detailed information as to why the exception is being thrown (ie why no columns are updated) or at least some reason why.
No records are deleted (they all appear in the originating software) and running a data integrity check on the originating software does not reveal any errors.