VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 8

Using the ADO Errors collection - Visual Basic 6 (VB6)

The ADO Errors collection is a set of Error objects that contain information about the last ADO operation that caused a provider error.

The first thing to note about the Errors collection is that it does not contain information about ADO errors. Instead, the Errors collection contains information about provider errors. ADO errors are raised as normal runtime errors in the VB environment.

Assume, for example, that you attempt to assign an invalid cursor type to a Recordset's CursorType property. Your attempt would generate a standard VB runtime error, because this is an ADO error.

On the other hand, if you call a SQL Server stored procedure and there is an abnormal termination in SQL Server, a provider error has occurred. The Errors collection will then get populated with one or more new entries.

Secondly, you should keep in mind that the Errors collection does not contain a history of errors generated during the current session.

The Errors collection contains only the last set of Error objects generated by the provider when attempting to fulfill a single ADO request. ADO uses a collection to handle errors because a single request might generate more than one error message from the provider.

The Errors collection is not cleared with every new ADO request to the Provider. Instead, the Errors collection keeps information about the last request that caused errors even through subsequent ADO requests to the provider. The Errors collection is cleared only when a new set of errors occurs.

You can use the Clear method of the Errors collection to keep track of whether the most recent ADO operation has caused Provider errors.

See Also


<< Previous | Contents | Next (Chapter 9) >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved