#DEFINE adfilterconflictingrecords 5 * Create the Connection ON ERROR erroradohandler(orecordset) oconnection = CREATEOBJECT("ADODB.Connection") oconnection.errors.CLEAR orecordset = CREATEOBJECT("ADODB.Recordset") oconnection.OPEN("Provider=SQLOLEDB;Server=GerryDeskTop;Database=FocusTest;User Id=SA;Password=;") *Example 1 - Create Database Constraint Error WITH orecordset .activeconnection = oconnection && Optimisitic Locking .locktype = 4 .OPEN("customer") .addnew && Record Not Allowed. Error should be raised here .FIELDS(0).VALUE=1111 .FIELDS(1).VALUE=" " && Effect All .updatebatch(3) ENDWITH FUNCTION erroradohandler(lorecordset) LOCAL lnerrornumber * Have We Got Errors in the Errors Collection of The Connection Object WITH lorecordset.activeconnection.errors IF .COUNT > 0 FOR lcnt = 1 TO .COUNT lnerrornumber = .ITEM(lcnt).NUMBER DO CASE &&& Constraint Error. This Line executes OK CASE lnerrornumber = -2147217873 IF handleconstraint(lorecordset) RETURN .T. ELSE RETURN .F. ENDIF OTHERWISE WAIT WINDOW "Unknown Error" ENDCASE ENDFOR ENDIF ENDWITH ENDFUNC FUNCTION handleconstraint(lorecordset) LOCAL lnrecordcount lcoldfilter lorecord && We Should have Records in the ADO Record Sets Filter WITH lorecordset &&& Hold old Filter lcoldfilter = .FILTER &&& Set Filter .FILTER = adfilterconflictingrecords lnrecordcount = .recordcount &&& If we Have Records in Filter ....... IF lnrecordcount > 0 &&& Ensure we at 1st Record IF !.BOF .movefirst ENDIF &&& Scan Records in Filter DO WHILE !.EOF &&& Examine status code in each field FOR lncnt = 1 TO .FIELDS.COUNT &&& HERE IS THE PROBLEM. STATUS PROPERTY IS ALWAYS ZERO lnstatuscode = .FIELDS(lncnt-1).STATUS ENDFOR .movenext ENDDO ENDIF ENDWITH ENDFUNC