hi guys! I just want to know if there is a better way, than the code below, for testing the connection to my ms sql 2000 server where in i can get the specific error message and "translate" it to words that my "dumb user" can understand. Thanks in advance!
Code:public static bool TestDBConnection(string ConnStr) { bool returnVal = false; SqlConnection sqlCon = new SqlConnection(ConnStr); try { sqlCon.Open(); returnVal = true; } catch (SqlException ex) { MessageBox.Show("Connection Failed!\r\nMessage: " + ex.Message, "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { sqlCon.Close(); } return returnVal; }




Reply With Quote