/[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

revision 123 by william, Sat Jul 14 11:14:09 2012 UTC revision 129 by william, Sat Jul 14 13:14:04 2012 UTC
# Line 2  Line 2 
2  using System.Collections.Generic;  using System.Collections.Generic;
3  using System.Text;  using System.Text;
4  using System.Data.SqlClient;  using System.Data.SqlClient;
5  using Microsoft.SqlServer.Management.Common;  using System.Linq;
6  using Microsoft.SqlServer.Management.Smo;  using System.Text.RegularExpressions;
   
7  namespace AnywhereTS.DBSupport  namespace AnywhereTS.DBSupport
8  {  {
9      public class MsSqlConnector : DBConnector<SqlParameter,SqlCommand,SqlConnection,SqlDataAdapter>      public class MsSqlConnector : DBConnector<SqlParameter,SqlCommand,SqlConnection,SqlDataAdapter>
# Line 17  namespace AnywhereTS.DBSupport Line 16  namespace AnywhereTS.DBSupport
16              ErrorInfo = null;              ErrorInfo = null;
17              try              try
18              {              {
19                  Server server = new Server(new ServerConnection(this.connection));                  var commands = Regex.Split(strFile, string.Format(@"^GO{0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline);
20                  server.ConnectionContext.ExecuteNonQuery(strFile);                  foreach (var command in commands)
21                    {
22                        Logging.DatabaseLog.DebugFormat("Current Command={0}", command);
23                        SqlCommand sqlcmd = this.CreateCommandInstance(command, new List<SqlParameter>(), out ErrorInfo);
24                        sqlcmd.CommandType = System.Data.CommandType.Text;
25                        if (ErrorInfo != null)
26                            throw ErrorInfo;
27                        sqlcmd.ExecuteNonQuery();
28                    }
29                  return true;                  return true;
30              }              }
31              catch (Exception ex)              catch (Exception ex)

Legend:
Removed from v.123  
changed lines
  Added in v.129

  ViewVC Help
Powered by ViewVC 1.1.22