/[AnywhereTS-MSSQL]/trunk/AnywhereTS.DBSupport/SqlMdfConnector.cs
ViewVC logotype

Diff of /trunk/AnywhereTS.DBSupport/SqlMdfConnector.cs

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

--- trunk/AnywhereTS.DBSupport/SqlMdfConnector.cs	2012/07/14 13:16:38	130
+++ trunk/AnywhereTS.DBSupport/SqlMdfConnector.cs	2012/07/15 05:13:20	134
@@ -15,10 +15,14 @@
             ErrorInfo = null;
             try
             {
-                string connetionString = null;
-                connetionString = GetConnectionString();
-                connection = new SqlConnection();
-                connection.ConnectionString = connetionString;
+                string connetionString = GetConnectionString();
+                using (log4net.NDC.Push(string.Format("connetionString={0}", connetionString)))
+                {
+                    Logging.DatabaseLog.Debug("Creating Connection");
+                    connection = new SqlConnection();
+                    connection.ConnectionString = connetionString;
+                    Logging.DatabaseLog.Debug("Created Connection");
+                }
             }
             //catch (SqlException ex) { Console.WriteLine(ex.ToString()); ErrorInfo = ex;  throw ErrorInfo;}
             catch (Exception ex) { Console.WriteLine(ex.ToString()); ErrorInfo = ex; throw ErrorInfo; }
@@ -38,10 +42,12 @@
                 foreach (var command in commands)
                 {
                     Logging.DatabaseLog.DebugFormat("Current Command={0}", command);
+                    SqlConnection sqlCon;
+                    this.GetConnectionClone(out sqlCon, out ErrorInfo);
                     SqlCommand sqlcmd = new SqlCommand(command, this.connection);
+                    sqlcmd.CommandText = command;
+                    sqlcmd.Connection = sqlCon;
                     sqlcmd.CommandType = System.Data.CommandType.Text;
-                    if (ErrorInfo != null)
-                        throw ErrorInfo;
                     sqlcmd.ExecuteNonQuery();
                 }
                 return true;
@@ -49,7 +55,7 @@
             catch (Exception ex)
             {
                 ErrorInfo = ex;
-                return false;
+                throw ErrorInfo;
             }
         }
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22