/[AnywhereTS-MSSQL]/trunk/TSAdminTool/Database.cs
ViewVC logotype

Diff of /trunk/TSAdminTool/Database.cs

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

--- trunk/TSAdminTool/Database.cs	2012/07/15 03:09:38	132
+++ trunk/TSAdminTool/Database.cs	2012/07/15 05:00:59	133
@@ -255,11 +255,26 @@
                 {
                     try
                     {
-                        SqlConnection sqlCon = conn.CreateConnection(out ErrorInfo);
+                        conn.CreateConnection(out ErrorInfo);
                         conn.OpenConnection(out ErrorInfo);
-                        //Logging.DatabaseLog.Debug(string.Format("Getting Coount of {0} databases", ATSGlobals.strDatabaseName));
-                        SqlCommand sqlCmd = new SqlCommand(string.Format("select count(*) from master..sysdatabases where name='{0}'", ATSGlobals.strDatabaseName), sqlCon);
-                        db_count = Convert.ToInt32(sqlCmd.ExecuteScalar());
+                        SqlConnection sqlCon;
+                        conn.GetConnectionClone(out sqlCon, out ErrorInfo);
+                        SqlCommand sqlCmd = new SqlCommand();
+                        sqlCmd.CommandText = string.Format("select count(*) from master..sysdatabases where name='{0}'", ATSGlobals.strDatabaseName);
+                        sqlCmd.CommandType = CommandType.Text;
+                        sqlCmd.Connection = sqlCon;
+                        try
+                        {
+                            db_count = Convert.ToInt32(sqlCmd.ExecuteScalar());
+                        }
+                        catch (Exception ex)
+                        {
+                            Exception e = ex.GetBaseException();
+                            using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", e.GetType().Name, e.Message, System.Environment.NewLine, e.ToString())))
+                            {
+                                Logging.DatabaseLog.Error(string.Format("sqlCmd.ExecuteScalar() failed"));
+                            }
+                        }
 
                         Logging.DatabaseLog.Info(string.Format("Found {0} databases named {1}", db_count, ATSGlobals.strDatabaseName));
                     }
@@ -353,12 +368,14 @@
                 {
                     try
                     {
-                        SqlConnection sqlCon = conn.CreateConnection(out ErrorInfo);
+                        conn.CreateConnection(out ErrorInfo);
                         conn.OpenConnection(out ErrorInfo);
-
-                        //Logging.DatabaseLog.Debug(string.Format("Getting Coount of {0} databases", ATSGlobals.strDatabaseName));
-
-                        SqlCommand sqlCmd = new SqlCommand(string.Format("SELECT value from {0}..AppInfo where property='version'", ATSGlobals.strDatabaseName), sqlCon);
+                        SqlConnection sqlCon;
+                        conn.GetConnectionClone(out sqlCon, out ErrorInfo);
+                        SqlCommand sqlCmd = new SqlCommand();
+                        sqlCmd.CommandText = string.Format("SELECT value from {0}..AppInfo where property='version'", ATSGlobals.strDatabaseName);
+                        sqlCmd.CommandType = CommandType.Text;
+                        sqlCmd.Connection = sqlCon;
                         string version = (string)sqlCmd.ExecuteScalar();
                         vDb = new Version(version);
                         Logging.DatabaseLog.Info(string.Format("Database {0} is at Version: {1}", ATSGlobals.strDatabaseName, version));

 

  ViewVC Help
Powered by ViewVC 1.1.22