Error Object
Connection Object
Errors Collection
EVENT: Connection::InfoMessage
InfoMessage
pError, adStatus, pConnection
The
InfoMessage
event can be fired if a warning occurs during a connection operation. It can provide additional information about the warning.
An event is simply a subroutine that can be called automatically after a specific operation has occurred. This subroutine can contain any code that you need to run when the event occurs. The subroutine will only be called if it is included in your code.
There are three parameters that are passed to this event.
The
pError
parameter is an
Error
object that contains information about the occurrence of any errors and/or warnings. This parameter requires that the
adStatus
parameter be set to the
adStatusOK
constant.
The
adStatus
parameter is one of the
EventStatusEnum
constants and defines the status of the event. When a warning occurs, it is set to
adStatusOK
. To prevent unwanted future firings of this event, set this parameter to
adStatusUnwantedEvent
before the event returns.
EventStatusEnum Constants
Constant
Value
Description
adStatusCancel
4
Cancels the operation that fired the event
adStatusCantDeny
3
Cannot cancel pending operation
adStatusErrorsOccurred
2
Indicates that warnings and/or errors occurred
adStatusOK
1
The operation that fired the event was successful
adStatusUnwantedEvent
5
The operation that generated the event cannot generate future events
The
pConnection
parameter is the
Connection
object that is associated with the warning that fired the event.
Code (Visual Basic):
' Use the WithEvents keyword to designate that events
' can be handled by this Connection object
Dim WithEvents objConn As ADODB.Connection
' Note how the object name, objConn, is incorporated into the event Sub name
Private Sub objConn_
InfoMessage
( ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pConnection As ADODB.Connection )
' place any code you desire here, for example
If adStatus = adStatusErrorsOccurred Then
Dim objError As ADODB.Error
For Each objError in pConnection.Errors
Debug.Print vbTab objError.Description
Next
End If
End Sub
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information