using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace AnywhereTS { public partial class frmConfigureControlPanel : Form { public frmConfigureControlPanel() { InitializeComponent(); } private void btnOk_Click(object sender, EventArgs e) { // Validate database server string dataServer; dataServer = textInput.Text.Trim(); //Create a connection to SQL Server SqlConnection sqlCon = new SqlConnection(); try { sqlCon.ConnectionString = Properties.Settings.Default.atsConnectionString; sqlCon.Open(); } catch (SqlException sql_ex) { MessageBox.Show("Could not connect to the datbase server. Please check your spelling and your connections. SQL Server error:\n" + sql_ex.Number.ToString() + " " + sql_ex.Message.ToString()); using (log4net.NDC.Push(string.Format("SqlException: ID={0} MESSAGE={1}{2}Diagnostics:{2}{3}", sql_ex.Number.ToString(), sql_ex.Message, System.Environment.NewLine, sql_ex.ToString()))) { using (log4net.NDC.Push(string.Format("ConnectionString={0}", Properties.Settings.Default.atsConnectionString))) { Logging.TSControlPanelLog.Error("Could not connect to the datbase server"); } } return; } // Save database server to variable and registry ProSupport.strDatabaseServer = textInput.Text; ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, ProSupport.strDatabaseServer); DialogResult = DialogResult.OK; //return } } }