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

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

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

--- trunk/AnywhereTS.DBSupport/MSSQLConnector.cs	2012/07/14 11:14:54	124
+++ trunk/AnywhereTS.DBSupport/MSSQLConnector.cs	2012/07/14 11:44:52	125
@@ -2,9 +2,8 @@
 using System.Collections.Generic;
 using System.Text;
 using System.Data.SqlClient;
-using Microsoft.SqlServer.Management.Common;
-using Microsoft.SqlServer.Management.Smo;
-
+using System.Linq;
+using System.Text.RegularExpressions;
 namespace AnywhereTS.DBSupport
 {
     public class MsSqlConnector : DBConnector<SqlParameter,SqlCommand,SqlConnection,SqlDataAdapter>
@@ -17,8 +16,14 @@
             ErrorInfo = null;
             try
             {
-                Server server = new Server(new ServerConnection(this.connection));
-                server.ConnectionContext.ExecuteNonQuery(strFile);
+                var commands = Regex.Split(strFile, string.Format(@"^GO${0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline);
+                foreach (var command in commands)
+                {
+                    SqlCommand sqlcmd = this.CreateCommandInstance(command, new List<SqlParameter>(), out ErrorInfo);
+                    if (ErrorInfo != null)
+                        throw ErrorInfo;
+                    sqlcmd.ExecuteNonQuery();
+                }
                 return true;
             }
             catch (Exception ex)

 

  ViewVC Help
Powered by ViewVC 1.1.22