Advantage .NET Data Provider
Occurs when the state of the AdsConnection object changes.
public event StateChangeEventHandler StateChange;
You can use this event to detect when a connection object is opened or closed.
The event handler receives an argument of type StateChangeEventArgs containing data related to this event. StateChangeEventArgs contains a CurrentState property that indicates the new state of the connection object and an OriginalState property that indicates the previous state.
static void OnConnectionStateChange( object sender, StateChangeEventArgs args )
Console.WriteLine( "Original State: " + args.OriginalState.ToString() );
Console.WriteLine( "Current State: " + args.CurrentState.ToString() );
public static void StateChangeTest()
AdsConnection conn = new AdsConnection( "data source = c:\\data" );
conn.StateChange += new StateChangeEventHandler( OnConnectionStateChange );
// cause event to fire for the change from Closed to Open
// cause event to fire for the change from Open to Closed
catch (Exception e)
Console.WriteLine( e.Message );