ADO Error object - SQLState Property

Home | About me | EXCEL VB Programming (XL97-2003) | ACCESS Programming | EXCEL VB.Net Programming | EXCEL Spreadsheet Functions Material Management  |  Guestbook
 

ADO Error object: SQLState Property

Syntax

objErr.SQLState

Returns a five character string that is the SQL error code.

The SQLState property is a string that contains the five-character SQL error code that is returned by the provider when an error occurs during the execution of an SQL command (query).
 
The SQL error codes are supposed to follow at least the minimum standards established by the "SQL Access Group." However, providers can vary greatly as to which portions of the SQL standards they recognize. You will need to consult the SQL documentation that is usually available from the provider in order to interpret the error code. Some SQL errors may not have a code and the returned value will be blank.

 

Example

For Each objError in objConnection
   ErrorInfo = "Description; " & objError.Description & VbCrLf &_
      "Help Context: " & objError.HelpContext & VbCrLf &_
      "Help File: " & objError.HelpFile & VbCrLf &_
      "Native Error: " & objError.NativeError & VbCrLf &_
      "Number: " & objError.Number & VbCrLf &_
      "Source: " & objError.Source & VbCrLf &_
      "SQL State: " & objError
.SQLState & VbCrLf

   Debug.Print ErrorInfo
Next