PreviousOLE DB Provider Guide ( revision 1) Next

Using Events

Show this topic in Library frames

Note: Great care must be exercised in using ADO events so that an event doesn't make a call that would generate more events. It is easy to get into a situation that would cause an infinite loop. One of the more obvious examples of that is using the WillMove event, instead of the MoveComplete event, to handle an end-of-file condition.

Private Sub Adodc1_WillMove(ByVal adReason As 
ADODB.EventReasonEnum, adStatus As 
ADODB.EventStatusEnum, ByVal pRecordset As 
ADODB.Recordset) 
    If Adodc1.Recordset.EOF Then 
Adodc1.Recordset.MoveLast 
End Sub 

This code will cause an infinite loop, which will ultimately fill up memory and generate an out of stack space error. This error handling should go into the Adodc1_MoveComplete event, instead.


Chapter contents
Publication contents

Prev topic: Using Bookmarks
Next topic: Using the Field Object