Question : CRecordset catch and error

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     {
          //     CustAccounts.SetAbsolutePosition( a+1);
          tempStorage = AccountList.GetAt(a);

//note: change struct var from type bool to char (BYTE)
          if( tempStorage.UseAct == true)
               use = '1';
          else
               use = '0';

          CustAccounts.Edit();    
          if (     CustAccounts.m_bStatement !=  use)
          {
               CustAccounts.m_bStatement =  use;
               try{
                    CustAccounts.Update();
               }
               catch(CDBException * e)
               {
                    CString errmsg = "The exception thrown :" + e->m_strError;
                    AfxMessageBox( errmsg,   MB_ICONSTOP    );
                    e->Delete();              
               }
          }
          CustAccounts.MoveNext();
          WinShow->Bar->SetPos(a);
     }
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.
Any suggestions??
Txs
 

Answer : CRecordset catch and error

>>Is it time to close off this quesiton ...

A question that describes the problem with your TEST
program (without any of the other complications) might be more visible and more easilty answered.

You never decribe the "originating software" and its nature might be relevant.  Is the "originating software" closed or open at the time you experience the error?

-- Dan
Random Solutions  
 
programming4us programming4us