The Connection Object - The BeginTransComplete Event
(Page 12 of 15 )
This event fires after a BeginTrans method call finishes executing.
BeginTransComplete(TransactionLevel, pError, _
adStatus, pConnection)
| Parameter | Type | Description |
|---|
| TransactionLevel | Long | Contains the new transaction level of the BeginTrans that caused the event |
| | |
| pError | Error | An Error object that describes the error that occurred if adStatus is adStatusErrorsOccurred (not set otherwise) |
| | |
| | |
| adStatus | EventStatus Enum (Long) | Identifies the status of the message |
| pConnection | Connection | The Connection object upon which the BeginTrans was executed |
You can use this to trigger other operations dependent upon the transaction having been started. For example, you might like to build a transaction monitoring system, and you could log the start of the transaction in this event.
The CommitTransComplete Event
This event fires after a CommitTrans method call finishes executing.
CommitTransComplete(pError, adStatus, pConnection)
| Parameter | Type | Description |
|---|
| pError | Error | An Error object that describes the error that occurred if adStatus is adStatusErrorsOccurred (not set otherwise) |
| adStatus | EventStatus Enum (Long) | Identifies the status of the message |
| pConnection | Connection | The Connection object upon which the CommitTrans was executed |
You can use this to trigger other operations that are dependent upon the transaction having been completed successfully, such as updating log files or an audit trail.
The ConnectComplete Event
This event fires after a connection is established.
ConnectComplete(pError, adStatus, pConnection)
| Parameter | Type | Description |
|---|
| pError | Error | An Error object that describes the error that occurred if adStatus is adStatusErrorsOccurred (not set otherwise) |
| adStatus | EventStatusEnum (Long) | Identifies the status of the event |
| pConnection | Connection | The Connection object for which this event applies |
You can use the ConnectComplete event to examine the details of the connection and whether it completed successfully. For example, the following Visual Basic example shows how you could use the ConnectComplete event:
Private Sub objConn_ConnectComplete( _
ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pConnection As ADODB.Connection)
Select Case adStatus
Case adStatusErrorsOccurred
Print "Errors occurred whilst attempting to connect."
Print "Connection String is: " & _
pConnection.ConnectionString
Print "Error description: " & pError.Description
Case adStatusOK
Print "Connection successful."
End Select
End Sub
The nonhighlighted code is the definition of the event procedure and is automatically created by Visual Basic. (For more on using events with Visual Basic, see Chapter 2.)
This is from ADO Programmer's Reference, by Dave Sussman (Apress, ISBN 1590593421). Check it out at your favorite bookstore today. Buy this book now. |
Next: The Disconnect Event >>
More ASP.NET Articles
More By Apress Publishing