How to detect whether the connection to SQL Server is broken or not

  For managed code, use SqlConnection’s StateChange event:           static void Main(string[] args)         {             SqlConnection conn = new SqlConnection();             conn.StateChange += ConnStateChangeEventHandler;             conn.ConnectionString = "server=yourServerName; uid=yourUserName; pwd=xxxx; database=northwind";             conn.Open();             try             {                 SqlCommand cmd = new SqlCommand();                 cmd.Connection = conn;                 cmd.CommandText = "select * from…

0