Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQLConnection.State

Status
Not open for further replies.

LastCyborg

Programmer
Joined
Feb 7, 2003
Messages
256
Location
MX
This component has an event that it supossed to be raised when the state changes, but it doesn't works.

I have been checking it by unplugging the network when the App is running
What am I doing wrong?
//The connection is ok
I have coded this:
Code:
private void sqlConnection1_StateChange(object sender, System.Data.StateChangeEventArgs e)
{	
   statusBarPanel1.Text = e.CurrentState.ToString();	
}
and also this code
Code:
private void sqlConnection1_StateChange(object sender, System.Data.StateChangeEventArgs e)
{	
   statusBarPanel1.Text = sqlConnection1.State.ToString();
}
I just want to show the status of the conection in my App
 
The code is Okay.
The event is raied only when the state change between Open and Closed ( available for now).
In order to see your handler working you should do one of the following:Close() or Dispose () on the connection object.
-obislavu-
 
So then, how can I show a message like in Kazaa where they show the status of your connection?

I wanna show the current state of the connection to the SQLServer.

I mean, if someone cuts the network it should say "Disconnected", etc.

 
I don't know of a way to actively monitor your database connection, but you could use the WMI classes to monitor the networking as a whole.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top