/[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 09:08:55	119
+++ trunk/AnywhereTS.DBSupport/SqlMdfConnector.cs	2012/07/14 13:16:38	130
@@ -2,7 +2,8 @@
 using System.Collections.Generic;
 using System.Text;
 using System.Data.SqlClient;
-
+using System.Linq;
+using System.Text.RegularExpressions;
 namespace AnywhereTS.DBSupport
 {
     public class SqlMdfConnector : DBConnector<SqlParameter, SqlCommand, SqlConnection, SqlDataAdapter>
@@ -28,20 +29,20 @@
             return string.Format(@"Data Source={0}\{1};AttachDbFilename=|DataDirectory|\{2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase);
         }
 
-        public override bool ClientRunScript(string[] strCommands, out Exception ErrorInfo)
+        protected override bool ClientRunScript(string strFile, out Exception ErrorInfo)
         {
             ErrorInfo = null;
             try
             {
-                foreach (string strCmd in strCommands)
+                var commands = Regex.Split(strFile, string.Format(@"^GO{0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline);
+                foreach (var command in commands)
                 {
-                    if (strCmd.Length > 0)
-                    {
-                        Logging.DatabaseLog.DebugFormat("Current Command: {0}{1}", System.Environment.NewLine, strCmd);
-                        // Substitute database directory with the decided one.
-                        SqlCommand command = this.CreateCommandInstance(strCmd, new List<SqlParameter>(), out ErrorInfo);
-                        command.ExecuteNonQuery();
-                    }
+                    Logging.DatabaseLog.DebugFormat("Current Command={0}", command);
+                    SqlCommand sqlcmd = new SqlCommand(command, this.connection);
+                    sqlcmd.CommandType = System.Data.CommandType.Text;
+                    if (ErrorInfo != null)
+                        throw ErrorInfo;
+                    sqlcmd.ExecuteNonQuery();
                 }
                 return true;
             }

 

  ViewVC Help
Powered by ViewVC 1.1.22