Occurs when this connection changes state.
Public Event StateChange As StateChangeEventHandler
public event override StateChangeEventHandler StateChange;
To process state change messages, you must create a System.Data.StateChangeEventHandler delegate and attach it to this event.
The following code defines a state change event handler.
' Visual Basic Private Sub MyStateHandler( _ obj As Object, args As StateChangeEventArgs _ ) System.Console.WriteLine( _ "StateHandler: " + args.OriginalState + " to " _ + args.CurrentState _ ) End Sub
The following code is the C# language equivalent:
// C# private void MyStateHandler( object obj, StateChangeEventArgs args ) { System.Console.WriteLine( "StateHandler: " + args.OriginalState + " to " + args.CurrentState ); }
The following code adds the MyStateHandler to the connection named conn.
' Visual Basic AddHandler conn.StateChange, AddressOf MyStateHandler
// C# conn.StateChange += new StateChangeEventHandler(MyStateHandler);