Bug #20826 | MySqlConnection.State does not report closed connection | ||
---|---|---|---|
Submitted: | 3 Jul 2006 16:51 | Modified: | 26 Sep 2006 19:28 |
Reporter: | vincent ugenti | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 1.0.7 | OS: | Windows (Windows 2000) |
Assigned to: | CPU Architecture: | Any |
[3 Jul 2006 16:51]
vincent ugenti
[7 Jul 2006 17:38]
Tonci Grgin
Hi Vincent and thanks for your problem report. Verified as described by reporter on MySQL server 5.0.24 BK on Suse 10, Win XP SP2 client: Output Server version: 5.0.24 Conn state: Open Shuting down server here Conn state(server down): Open Code snipet class Program { readonly static string connstr = "Server=munja;Database=Bug20084;Username=root;Password=;Port=3307;allowzerodatetime=true;"; static void Main(string[] args) { using (MySqlConnection con = new MySqlConnection(connstr)) { //20826 con.Open(); Console.WriteLine("Server version: " + con.ServerVersion); Console.WriteLine("Conn state: " + con.State); Console.WriteLine("Shuting down server here"); Console.WriteLine("Conn state(server down): " + con.State);
[26 Sep 2006 19:28]
Reggie Burnett
This is not a bug. The state property does not and should not query the server to make sure it's still alive. SqlClient doesn't do this either. Code that exeuctes queries has to be guarded with try catch. Checking the state property is not enough. The server could go down after the state property is checked and before the query is executed.
[7 Oct 2008 21:19]
Jorge Estrada
You can see if yu're disconnected by sending a Ping() to MySQL: If ConexionMysql.Ping() = False Then ...