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

revision 119 by william, Sat Jul 14 09:08:55 2012 UTC revision 130 by william, Sat Jul 14 13:16:38 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 System.Linq;
6    using System.Text.RegularExpressions;
7  namespace AnywhereTS.DBSupport  namespace AnywhereTS.DBSupport
8  {  {
9      public class SqlMdfConnector : DBConnector<SqlParameter, SqlCommand, SqlConnection, SqlDataAdapter>      public class SqlMdfConnector : DBConnector<SqlParameter, SqlCommand, SqlConnection, SqlDataAdapter>
# Line 28  namespace AnywhereTS.DBSupport Line 29  namespace AnywhereTS.DBSupport
29              return string.Format(@"Data Source={0}\{1};AttachDbFilename=|DataDirectory|\{2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase);              return string.Format(@"Data Source={0}\{1};AttachDbFilename=|DataDirectory|\{2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase);
30          }          }
31    
32          public override bool ClientRunScript(string[] strCommands, out Exception ErrorInfo)          protected override bool ClientRunScript(string strFile, out Exception ErrorInfo)
33          {          {
34              ErrorInfo = null;              ErrorInfo = null;
35              try              try
36              {              {
37                  foreach (string strCmd in strCommands)                  var commands = Regex.Split(strFile, string.Format(@"^GO{0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline);
38                    foreach (var command in commands)
39                  {                  {
40                      if (strCmd.Length > 0)                      Logging.DatabaseLog.DebugFormat("Current Command={0}", command);
41                      {                      SqlCommand sqlcmd = new SqlCommand(command, this.connection);
42                          Logging.DatabaseLog.DebugFormat("Current Command: {0}{1}", System.Environment.NewLine, strCmd);                      sqlcmd.CommandType = System.Data.CommandType.Text;
43                          // Substitute database directory with the decided one.                      if (ErrorInfo != null)
44                          SqlCommand command = this.CreateCommandInstance(strCmd, new List<SqlParameter>(), out ErrorInfo);                          throw ErrorInfo;
45                          command.ExecuteNonQuery();                      sqlcmd.ExecuteNonQuery();
                     }  
46                  }                  }
47                  return true;                  return true;
48              }              }

Legend:
Removed from v.119  
changed lines
  Added in v.130

  ViewVC Help
Powered by ViewVC 1.1.22