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

Contents of /trunk/TSControlPanel/frmConfigureControlPanel.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91 - (show annotations) (download)
Sat Jul 14 00:36:23 2012 UTC (7 years, 11 months ago) by william
File size: 2875 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using System.Data.SqlClient;
9 using AnywhereTS.DBSupport;
10
11 namespace AnywhereTS
12 {
13 public partial class frmConfigureControlPanel : Form
14 {
15 public frmConfigureControlPanel()
16 {
17 InitializeComponent();
18 }
19
20 private void btnOk_Click(object sender, EventArgs e)
21 {
22 // Validate database server
23 string dataServer;
24 dataServer = textInput.Text.Trim();
25 //Create a connection to SQL Server
26 Exception ErrorInfo = null;
27 Logging.ATSAdminLog.Debug("frmConfigureControlPanel.btnOk_Click() called ");
28 using (MsSqlConnector conn = new MsSqlConnector(Properties.Settings.Default.DBServer, Properties.Settings.Default.DBInstance, "master"))
29 {
30 try
31 {
32 conn.CreateConnection(out ErrorInfo);
33 conn.OpenConnection(out ErrorInfo);
34
35 // create datagbase
36 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("SqlException: ID={0} MESSAGE={1}{2}Diagnostics:{2}{3}", ex.Number.ToString(), ex.Message, System.Environment.NewLine, ex.ToString())))
44 {
45 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 }
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
60 ProSupport.strAnywhereTSServer = textInput.Text;
61 ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, ProSupport.strAnywhereTSServer);
62 DialogResult = DialogResult.OK; //return
63 }
64 }
65 }

  ViewVC Help
Powered by ViewVC 1.1.22