An Error object contains details about data access errors pertaining to a single operation involving ADO.
Description, HelpContext, HelpFile, NativeError, Number, Source, SQLState
You can read an Error objects properties to obtain specific details about each error, including the following:
· The Description property, which contains the text of the error alert.
· The Number property, which contains the Long integer value of the error constant.
· The Source property, which 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, which indicate the appropriate Microsoft Windows Help file and Help topic, respectively, (if any exist) for the error.
· The SQLState and NativeError properties, which provide information from ODBC data sources.
When a provider error occurs, it is placed in the Errors collection of the Connection object. If there is no valid Connection object, you will need to retrieve error information from the Microsoft® Visual Basic® for Applications Err object. ADO supports the return of multiple errors by a single ADO operation to allow for error information specific to the provider.
ADO can return the following specific errors:
Constant Name |
Number |
Description |
adErrInvalidArgument |
3001 |
You are using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another. |
adErrNoCurrentRecord |
3021 |
Either BOF or EOF is True, or the current record has been deleted; the operation you requested requires a current record. |
adErrIllegalOperation |
3219 |
The operation you requested is not allowed in this context. |
adErrInTransaction |
3246 |
You may not explicitly close a Connection object while in the middle of a transaction. |
adErrFeatureNotAvailable |
3251 |
The operation you requested is not supported by the provider. |
adErrItemNotFound |
3265 |
ADO could not find the object in the collection corresponding to the requested name or ordinal reference. |
adErrObjectNotSet |
3420 |
The object reference you are using no longer points to a valid object. |
adErrDataConversion |
3421 |
You are using a value of the wrong type for the current operation. |
adErrObjectClosed |
3704 |
The operation you requested is not allowed if the object is closed. |
adErrObjectOpen |
3705 |
The operation you requested is not allowed if the object is open. |
adErrProviderNotFound |
3706 |
ADO could not find the specified provider. |
adErrBoundToCommand |
3707 |
You cannot change the ActiveConnection property of a Recordset object with a Command object as its source. |
adErrInvalidParamInfo |
3708 |
You have improperly defined a Parameter object. |
adErrInvalidConnection |
3709 |
You requested an operation on an object with a reference to a closed or invalid Connection object. |
Just as providers do, ADO clears the OLE Error Info object before making a call that could potentially generate a new error. However, the Errors collection on the Connection object is cleared and populated only when ADO or the provider generates a new error.
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 Delete, 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.
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)