/[AnywhereTS-MSSQL]/trunk/TSControlPanel/frmConfigureControlPanel.cs
ViewVC logotype

Diff of /trunk/TSControlPanel/frmConfigureControlPanel.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 90 by william, Thu Jul 12 16:21:35 2012 UTC revision 91 by william, Sat Jul 14 00:36:23 2012 UTC
# Line 6  using System.Drawing; Line 6  using System.Drawing;
6  using System.Text;  using System.Text;
7  using System.Windows.Forms;  using System.Windows.Forms;
8  using System.Data.SqlClient;  using System.Data.SqlClient;
9    using AnywhereTS.DBSupport;
10    
11  namespace AnywhereTS  namespace AnywhereTS
12  {  {
# Line 22  namespace AnywhereTS Line 23  namespace AnywhereTS
23              string dataServer;              string dataServer;
24              dataServer = textInput.Text.Trim();              dataServer = textInput.Text.Trim();
25              //Create a connection to SQL Server              //Create a connection to SQL Server
26              SqlConnection sqlCon = new SqlConnection();              Exception ErrorInfo = null;
27              try              Logging.ATSAdminLog.Debug("frmConfigureControlPanel.btnOk_Click() called ");
28                using (MsSqlConnector conn = new MsSqlConnector(Properties.Settings.Default.DBServer, Properties.Settings.Default.DBInstance, "master"))
29              {              {
30                  sqlCon = new SqlConnection(Properties.Settings.Default.atsConnectionString.Replace("AnywhereTS", "master"));                  try
31                  sqlCon.Open();                  {
32              }                      conn.CreateConnection(out ErrorInfo);
33              catch (SqlException sql_ex)                      conn.OpenConnection(out ErrorInfo);
34              {  
35                  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());                      // create datagbase
36                  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())))                      Logging.ATSAdminLog.Info(string.Format("Opening Database {0}", ATSGlobals.strDatabaseName));
37    
38    
39                        Logging.ATSAdminLog.Info(string.Format("Opened Database {0}", ATSGlobals.strDatabaseName));
40                    }
41                    catch (SqlException ex)
42                  {                  {
43                      using (log4net.NDC.Push(string.Format("ConnectionString={0}", Properties.Settings.Default.atsConnectionString)))                      using (log4net.NDC.Push(string.Format("SqlException: ID={0} MESSAGE={1}{2}Diagnostics:{2}{3}", ex.Number.ToString(), ex.Message, System.Environment.NewLine, ex.ToString())))
44                      {                      {
45                          Logging.TSControlPanelLog.Error("Could not connect to the datbase server");                          Logging.DatabaseLog.Error(string.Format("Failed to open Database {0}", ATSGlobals.strDatabaseName));
46                      }                      }
47                        ErrorInfo = ex; throw ErrorInfo;
48                    }
49                    catch (Exception ex)
50                    {
51                        using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
52                        {
53                            Logging.DatabaseLog.Error(string.Format("Failed to open Database {0}", ATSGlobals.strDatabaseName));
54                        }
55                        ErrorInfo = ex; throw ErrorInfo;
56                  }                  }
                 return;  
57              }              }
58                if (ErrorInfo != null) { MessageBox.Show(string.Format("Failed to open database {0}. Please check the log for errors.", ATSGlobals.strDatabaseName)); }
   
59              // Save database server to variable and registry              // Save database server to variable and registry
60              ProSupport.strDatabaseServer = textInput.Text;              ProSupport.strAnywhereTSServer = textInput.Text;
61              ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, ProSupport.strDatabaseServer);              ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, ProSupport.strAnywhereTSServer);
   
62              DialogResult = DialogResult.OK; //return              DialogResult = DialogResult.OK; //return
63          }          }
64      }      }

Legend:
Removed from v.90  
changed lines
  Added in v.91

  ViewVC Help
Powered by ViewVC 1.1.22