ADO InfoMessage Event

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

ADO InfoMessage Event

An event is a subroutine that can be called automatically after a specific operation has occurred.

The InfoMessage event can be fired if a warning occurs in a connection operation.

Syntax

InfoMessage objerror,status,objconn

Example

' 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

 

Parameter

Description

objerror An Error object that contains the errors that are returned
status An EventStatusEnum value. If a warning occurs, status is set to adStatusOK and the objerror contains the warning
objconn A Connection object. The connection for which the warning occurred

EventStatusEnum Values

Constant Value

Description

adStatusOK 1 The operation that fired the event was successful
adStatusErrorsOccurred 2 The operation that fired the event failed
adStatusCantDeny 3 Cannot cancel the pending operation
adStatusCancel 4 Cancels the operation that fired the event
adStatusUnwantedEvent 5 Prevents subsequent notifications before the event method has finished executing