'Declaration Public MustInherit Class TransactionStateChangeEventArgs Inherits System.EventArgs
public abstract class TransactionStateChangeEventArgs : System.EventArgs
'Declaration Public MustInherit Class TransactionStateChangeEventArgs Inherits System.EventArgs
public abstract class TransactionStateChangeEventArgs : System.EventArgs
SqlConnection connection = new SqlConnection( "User Id=sa;Server=localhost;Initial Catalog=Test;"); connection.TransactionStateChanged += new TransactionStateChangedEventHandler(connection_TransactionStateChange); connection.TransactionStateChanging += new TransactionStateChangingEventHandler(connection_TransactionStateChange); connection.Open(); // ... SqlTransaction transaction = connection.BeginTransaction(); // ... transaction.Commit(); // ... void connection_TransactionStateChange(object sender, TransactionStateChangeEventArgs e) { // common actions that must be done before and after the transaction state change // ... if (e is TransactionStateChangingEventArgs) { // actions before the transaction state change // ... } else { // e is TransactionStateChangedEventArgs // actions after the transaction state change // ... } }
Dim connection As New SqlConnection( _ "User Id=sa;Server=localhost;Initial Catalog=Test;") AddHandler connection.TransactionStateChanged, New TransactionStateChangedEventHandler(AddressOf &_ Me.connection_TransactionStateChange) AddHandler connection.TransactionStateChanging, New TransactionStateChangingEventHandler(AddressOf &_ Me.connection_TransactionStateChange) connection.Open() ' ... Dim Transaction As OracleTransaction Transaction = connection.BeginTransaction() ' ... Transaction.Commit() ' ... Private Sub connection_TransactionStateChange(ByVal sender As Object, ByVal e As TransactionStateChangeEventArgs) ' common actions that must be done before and after the transaction state change '... If TypeOf e Is TransactionStateChangingEventArgs Then ' actions before the transaction state change ' ... Else ' e is TransactionStateChangedEventArgs ' actions after the transaction state change ' ... End If End Sub
System.Object
System.EventArgs
Devart.Common.TransactionStateChangeEventArgs
Devart.Common.TransactionStateChangedEventArgs
Devart.Common.TransactionStateChangingEventArgs
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2