Remarks

Each OLEDBError object represents an error returned by the most recent OLE DB query. If the specified OLE DB query runs without error, the OLEDBErrors collection is empty. The errors in the collection are indexed in the order in which they're generated by the OLE DB provider. You cannot add members to the collection.

Example

Use the property to return the OLEDBErrors collection. The following example displays the error description and the property's value for each OLE DB error in the collection.

Visual Basic for Applications
For Each objEr in Application.OLEDBErrors MsgBox "The following error occurred:" & _ objEr.ErrorString & " : " & objEr.SqlState Next objEr

Use OLEDBErrors(), where is the index number of the OLE DB error, to return a single OLEDBErrorobject. The following example displays the error description and the SqlStateproperty's value for the first error returned by the most recent OLE DB query.

Visual Basic for Applications
Set objEr = Application.OLEDBErrors(1) MsgBox "The following error occurred:" & _ objEr.ErrorString & " : " & objEr.SqlState
OLEDB Errors Collection Object

See also:

index index