using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; using System.Linq; using System.Text.RegularExpressions; namespace AnywhereTS.DBSupport { public class MsSqlConnector : DBConnector { public MsSqlConnector(string DBServerAddress, string DBServerInstance, string DBDatabase) : base(DBServerAddress, DBServerInstance, DBDatabase) { } protected override bool ClientRunScript(string strFile, out Exception ErrorInfo) { ErrorInfo = null; try { var commands = Regex.Split(strFile, string.Format(@"^GO{0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline); 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; sqlcmd.ExecuteNonQuery(); } return true; } catch (Exception ex) { ErrorInfo = ex; throw ErrorInfo; } } } }