Class OLEDBError (Excel VBA)
The class OLEDBError represents an OLE DB error returned by the most recent OLE DB query. To use a OLEDBError class variable it first needs to be instantiated, for example
Dim oleer as OLEDBError
Set oleer = Application.OLEDBErrors(Index:=1)
For Each
Here is an example of processing the OLEDBError items in a collection.
Dim oleer As OLEDBError
For Each oleer In Application.OLEDBErrors
Next oleer
ErrorString
Returns a String value that represents the ODBC error string.
Dim strErrorString As String
strErrorString = Application.OLEDBErrors(1).ErrorString
Native
Returns a provider-specific numeric value that specifies an error. The error number corresponds to an error condition that resulted after the most recent OLE DB query.
Dim lngNative As Long
lngNative = Application.OLEDBErrors(1).Native
Number
Returns a numeric value that specifies an error. The error number corresponds to a unique trap number corresponding to an error condition that resulted after the most recent OLE DB query.
Dim lngNumber As Long
lngNumber = Application.OLEDBErrors(1).Number
SqlState
Returns the SQL state error.
For an explanation of the specific error, see your SQL documentation.
Dim strSqlState As String
strSqlState = Application.OLEDBErrors(1).SqlState
Stage
Returns a numeric value specifying the stage of an error that resulted after the most recent OLE DB query.
Dim lngStage As Long
lngStage = Application.OLEDBErrors(1).Stage