An Error object contains details about data access errors pertaining to a single operation involving ADO.
Properties
Description, HelpContext, HelpFile, NativeError, Number, Source, SQLState
Remarks
You can read an Error object’s properties to obtain specific details about each error, including the following:
When a provider error occurs, it is placed in the Errors collection of the Connection object. ADO supports the return of multiple errors by a single ADO operation to allow for error information specific to the provider.
Microsoft Visual Basic If there is no valid Connection object, you will need to retrieve error information from the Err object.
ADO can return the following specific errors:
| Constant Name | Number | Description |
| adErrInvalidArgument | 3001 | The application is 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 requested by the application requires a current record. |
| adErrIllegalOperation | 3219 | The operation requested by the application is not allowed in this context. |
| adErrInTransaction | 3246 | The application may not explicitly close a Connection object while in the middle of a transaction. |
| adErrFeatureNotAvailable | 3251 | The operation requested by the application is not supported by the provider. |
| adErrItemNotFound | 3265 | ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application. |
| Can't append. Object already in collection. | ||
| adErrObjectNotSet | 3420 | The object referenced by the application no longer points to a valid object. |
| adErrDataConversion | 3421 | The application is using a value of the wrong type for the current operation. |
| adErrObjectClosed | 3704 | The operation requested by the application is not allowed if the object is closed. |
| adErrObjectOpen | 3705 | The operation requested by the application is not allowed if the object is open. |
| adErrProviderNotFound | 3706 | ADO could not find the specified provider. |
| adErrBoundToCommand | 3707 | The application cannot change the ActiveConnectionadproActiveConnection property of a RecordsetadobjRecordset object with a CommandadobjCommand object as its source. |
| adErrInvalidParamInfo | The application has improperly defined a ParameteradobjParameter object. | |
| adErrInvalidConnection | The application requested an operation on an object with a reference to a closed or invalid Connection object. | |
| Invalid operation on object while processing event. | ||
| Invalid operation on object while processing another command. | ||
| Operation has been cancelled by the user. | ||
| Invalid operation on object while still connecting. |
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)
See Also
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.