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

Annotation of /trunk/TSControlPanel/frmConfigureControlPanel.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92 - (hide annotations) (download)
Sat Jul 14 00:55:41 2012 UTC (8 years, 10 months ago) by william
File size: 2861 byte(s)

1 william 4 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 william 91 using AnywhereTS.DBSupport;
10 william 4
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 william 91 Exception ErrorInfo = null;
27     Logging.ATSAdminLog.Debug("frmConfigureControlPanel.btnOk_Click() called ");
28 william 92 using (MsSqlConnector conn = new MsSqlConnector(ProSupport.strDatabaseServer, ProSupport.strDatabaseInstance, "master"))
29 william 4 {
30 william 91 try
31 william 46 {
32 william 91 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 william 49 {
45 william 91 Logging.DatabaseLog.Error(string.Format("Failed to open Database {0}", ATSGlobals.strDatabaseName));
46 william 49 }
47 william 91 ErrorInfo = ex; throw ErrorInfo;
48 william 46 }
49 william 91 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 william 4 }
58 william 91 if (ErrorInfo != null) { MessageBox.Show(string.Format("Failed to open database {0}. Please check the log for errors.", ATSGlobals.strDatabaseName)); }
59 william 4 // Save database server to variable and registry
60 william 91 ProSupport.strAnywhereTSServer = textInput.Text;
61 william 92 ATSGlobals.SetATSRegValue(ProSupport.strRegAnywhereTSServer, ProSupport.strAnywhereTSServer);
62 william 4 DialogResult = DialogResult.OK; //return
63     }
64     }
65     }

  ViewVC Help
Powered by ViewVC 1.1.22