Product Home Page | Developer Site | Version | |
A descriptive string associated with an Error object. This property is not currently supported on UNIX.
Returns a String value.
Use the Description property to obtain a short description of the error. Display this property to alert the user to an error that you cannot or do not want to handle. The string will come from either ADO or a provider.
Providers are responsible for passing specific error text to ADO. ADO adds an Error object to the ADO Errors Collection for each provider error or warning it receives. Enumerate the Errors collection to trace the errors that the provider passes.
This Visual Basic example triggers an error, traps it, and displays the ADO Error Object Description Property, ADO Error Object HelpContext, HelpFile Property, ADO Error Object NativeError Property, ADO Error Object Number Property, ADO Error Object Source Property, and ADO Error Object SQLState Property properties of the resulting Error object:
Public Sub DescriptionX()
Dim cnn1 As ADODB.Connection
Dim errLoop As ADODB.Error
Dim strError As String
On Error GoTo ErrorHandler
` Intentionally trigger an error.
Set cnn1 = New ADODB.Connection
cnn1.Open "nothing"
Exit Sub
ErrorHandler:
` Enumerate Errors collection and display
` properties of each Error object.
For Each errLoop In cnn1.Errors
strError = "Error #" & errLoop.Number & vbCr & _
" " & errLoop.Description & vbCr & _
" (Source: " & errLoop.Source & ")" & vbCr & _
" (SQL State: " & errLoop.SQLState & ")" & vbCr & _
" (NativeError: " & errLoop.NativeError & ")" & vbCr
If errLoop.HelpFile = "" Then
strError = strError & _
" No Help file available" & _
vbCr & vbCr
Else
strError = strError & _
" (HelpFile: " & errLoop.HelpFile & ")" & vbCr & _
" (HelpContext: " & errLoop.HelpContext & ")" & _
vbCr & vbCr
End If
Debug.Print strError
Next
Resume Next
End Sub
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.