ADO 2.5

Anticipating Errors

Error prevention is at least as important as error handling. This final section contains a short list of precautions your application can take to help make errors less likely to occur.

Check the state of objects by checking the value in the State property before trying to perform an operation using those objects. For example, if your application uses a global Connection, check its State property to see if it is already open before calling the Open method.

Check the data before you try to write any data to the data store. The easiest way to do so is to handle the WillMove event or the WillUpdateRecordset event. For a more complete discussion of handling ADO events, see Chapter 7: Handling ADO Events.

Make sure that Recordset objects are not beyond the boundaries of the Recordset before attempting to move the record pointer. If you try to MoveNext when EOF is True or MovePrev when BOF is True, an error will occur. If you perform any of the Move methods when both EOF and BOF are True, an error will be generated.

Errors also will occur if you try to perform operations such as Seek and Find on an empty Recordset.

© 1998-2003 Microsoft Corporation. All rights reserved.