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 |
|
|
|
10 |
|
|
namespace AnywhereTS |
11 |
|
|
{ |
12 |
|
|
public partial class frmConfigureControlPanel : Form |
13 |
|
|
{ |
14 |
|
|
public frmConfigureControlPanel() |
15 |
|
|
{ |
16 |
|
|
InitializeComponent(); |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
private void btnOk_Click(object sender, EventArgs e) |
20 |
|
|
{ |
21 |
|
|
// Validate database server |
22 |
|
|
string dataServer; |
23 |
|
|
dataServer = textInput.Text.Trim(); |
24 |
|
|
//Create a connection to SQL Server |
25 |
|
|
SqlConnection sqlCon = new SqlConnection(); |
26 |
|
|
try |
27 |
|
|
{ |
28 |
william |
17 |
sqlCon.ConnectionString = Properties.Settings.Default.atsConnectionString; |
29 |
william |
4 |
sqlCon.Open(); |
30 |
|
|
} |
31 |
|
|
catch (SqlException sql_ex) |
32 |
|
|
{ |
33 |
william |
17 |
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()); |
34 |
william |
46 |
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()))) |
35 |
|
|
{ |
36 |
|
|
Logging.ATSAdminLog.Error("Could not connect to the datbase server"); |
37 |
|
|
} |
38 |
william |
4 |
return; |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
// Save database server to variable and registry |
43 |
|
|
ProSupport.strDatabaseServer = textInput.Text; |
44 |
|
|
ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseServer, ProSupport.strDatabaseServer); |
45 |
|
|
|
46 |
|
|
DialogResult = DialogResult.OK; //return |
47 |
|
|
} |
48 |
|
|
} |
49 |
|
|
} |