/[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 89 by william, Fri Jul 13 22:56:50 2012 UTC revision 128 by william, Sat Jul 14 13:01:52 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 25  namespace AnywhereTS.DBSupport Line 26  namespace AnywhereTS.DBSupport
26    
27          new public static string GetConnectionString()          new public static string GetConnectionString()
28          {          {
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            protected override bool ClientRunScript(string strFile, out Exception ErrorInfo)
33            {
34                ErrorInfo = null;
35                try
36                {
37                    var commands = Regex.Split(strFile, string.Format(@"^GO${0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline);
38                    foreach (var command in commands)
39                    {
40                        SqlCommand sqlcmd = this.CreateCommandInstance(command, new List<SqlParameter>(), out ErrorInfo);
41                        sqlcmd.CommandType = System.Data.CommandType.Text;
42                        if (ErrorInfo != null)
43                            throw ErrorInfo;
44                        sqlcmd.ExecuteNonQuery();
45                    }
46                    return true;
47                }
48                catch (Exception ex)
49                {
50                    ErrorInfo = ex;
51                    return false;
52                }
53          }          }
54      }      }
55  }  }

Legend:
Removed from v.89  
changed lines
  Added in v.128

  ViewVC Help
Powered by ViewVC 1.1.22