--- trunk/AnywhereTS.DBSupport/DBConnector.cs 2012/07/14 09:08:21 118 +++ trunk/AnywhereTS.DBSupport/DBConnector.cs 2012/07/14 09:08:55 119 @@ -47,7 +47,7 @@ namespace AnywhereTS.DBSupport public static string GetConnectionString() { - return string.Format(@"Data Source={0}\{1};Initial Catalog={2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase); + return string.Format(@"Data Source={0}\{1};Database={2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase); } protected DBConnection connection; #region DBServerAddress, DBServerInstance, DBDatabase @@ -290,12 +290,12 @@ namespace AnywhereTS.DBSupport public string[] ParseScriptToCommands(string strScript) { string[] commands; - commands = Regex.Split(strScript, "GO\r\n", RegexOptions.IgnoreCase); + commands = strScript.Split(new string[] { string.Format("GO{0}", System.Environment.NewLine) }, StringSplitOptions.RemoveEmptyEntries); return commands; } #endregion #region public virtual bool RunScript(string strFile, out Exception ErrorInfo) - public virtual bool RunScript(string strFile, out Exception ErrorInfo) + public bool RunScript(string strFile, out Exception ErrorInfo) { ErrorInfo = null; try @@ -304,20 +304,14 @@ namespace AnywhereTS.DBSupport strCommands = ParseScriptToCommands(strFile); if (this.ConnectionIsOpen) { - foreach (string strCmd in strCommands) + if (!ClientRunScript(strCommands, out ErrorInfo)) { - if (strCmd.Length > 0) - { - // Substitute database directory with the decided one. - DBCommand command = this.CreateCommandInstance(strCmd, new List(), out ErrorInfo); - command.ExecuteNonQuery(); - } + return false; } - return true; } else { - Logging.ATSAdminLog.Fatal(string.Format("Failed to run script: [database connection is not open] {0}{1}", System.Environment.NewLine, strFile)); + Logging.DatabaseLog.Fatal(string.Format("Failed to run script: [database connection is not open] {0}{1}", System.Environment.NewLine, strFile)); return false; } } @@ -339,6 +333,7 @@ namespace AnywhereTS.DBSupport } return false; } + public abstract bool ClientRunScript(string[] strCommands, out Exception ErrorInfo); #endregion #endregion