Previous PageNext Page

9.4.1 Description Property

A descriptive string associated with an Error object.
 

Return Values

Returns a String value.
 

Remarks

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 Errors collection for each provider error or warning it receives. Enumerate the Errors collection to trace the errors that the provider passes.
 

Example

This Visual Basic example triggers an error, traps it, and displays the Description, HelpContext, HelpFile, NativeError, Number, Source, and SQLState 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 © 2000 Chili!Soft

Previous PageTop Of PageNext Page