9.4 Error Object

Provides specific details about each ADO error.
Properties
Description
|
A descriptive string associated with an error.
|
HelpContext
|
The help file topic associated with an error.
|
HelpFile
|
The help file associated with an error.
|
NativeError
|
The provider-specific error code for an error.
|
Number
|
The number that uniquely identifies an error.
|
Source
|
The name of the object or application that originally generated the error.
|
SQLState
|
The SQL state for a given error.
|
Remarks
Any operation involving ADO objects can generate one or more provider errors. As each error occurs, one or more Error objects are placed in the Errors collection of the Connection object. When another ADO operation generates an error, the Errors collection is cleared, and the new set of Error objects are placed in the Errors collection.
Note:
Each Error object represents a specific provider error, not an ADO error. ADO errors are exposed to the run-time exception handling mechanism. For example, in Microsoft Visual Basic, the occurrence of an ADO-specific error will trigger an On Error event and appear in the Err object. For a complete list of ADO errors, see Appendix B.
The read the Error object's properties to obtain specific details about each error:
- The Description property contains the text of the error.
- The Number property contains the Long integer value of the error constant.
- The Source property identifies the object that raised the error. This is particularly useful when you have several Error objects in the Errors collection following a request to a data source.
- The HelpFile and HelpContext properties indicate the appropriate Microsoft Windows Help file and Help topic, respectively, (if any exist) for the error.
- The SQLState and NativeError properties provide information from SQL data sources.
ADO supports the return of multiple errors by a single ADO operation to allow for error information specific to the provider. To obtain this error information in an error handler, use the appropriate error-trapping features of the language or environment you are working with, then use nested loops to enumerate the properties of each Error object in the Errors collection.
ADO clears the OLE Error Info object before making a call that could potentially generate a new provider error. However, the Errors collection on the Connection object is cleared and populated only when the provider generates a new error, or when the Clear method is called.
Some properties and methods return warnings that appear as Error objects in the Errors collection but do not halt a program's execution. Before you call the Resync, UpdateBatch, or CancelBatch methods on a Recordset object, or before you set the Filter property on a Recordset object, call the Clear method on the Errors collection so that you can read the Count property of the Errors collection to test for returned warnings.
If there is no valid Connection object when using Microsoft Visual Basic and VBScript, retrieve error information from the Err object.
To refer to an Error object in a collection by its ordinal number, use either of the following syntax forms:
connection.Errors.Item(0)
connection.Errors(0)
Copyright © 2000 Chili!Soft
|