StateChange
StateChangeEventHandler StateChange
Fires when the connection is opened or closed. This event provides a
StateChangeEventArgs
object with information about
the current and previous state as a value from the
System.Data.ConnectionState
enumeration.
StateChangeEventArgs e
Provides two properties. CurrentState
indicates
the current state of the connection (which triggered the
StateChange
event), and
OriginalState
indicates the state of the
Connection
object before the event was fired.
Here’s an example method that handles the
StateChange
event and displays some information to
a console window:
private void OnStateChange(object sender, StateChangeEventArgs e) { Console.WriteLine("Original State = " + e.OriginalState); Console.WriteLine("Current State = " + e.CurrentState); }