/[AnywhereTS-MSSQL]/trunk/AnywhereTS.DBSupport/MSSQLConnector.cs
ViewVC logotype

Contents of /trunk/AnywhereTS.DBSupport/MSSQLConnector.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 129 - (show annotations) (download)
Sat Jul 14 13:14:04 2012 UTC (9 years, 3 months ago) by william
File size: 1481 byte(s)
+ fix regex (we made changes then reverted those changes, the changes were lost) -- being them back

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Data.SqlClient;
5 using System.Linq;
6 using System.Text.RegularExpressions;
7 namespace AnywhereTS.DBSupport
8 {
9 public class MsSqlConnector : DBConnector<SqlParameter,SqlCommand,SqlConnection,SqlDataAdapter>
10 {
11 public MsSqlConnector(string DBServerAddress, string DBServerInstance, string DBDatabase) : base(DBServerAddress, DBServerInstance, DBDatabase) { }
12
13
14 protected override bool ClientRunScript(string strFile, out Exception ErrorInfo)
15 {
16 ErrorInfo = null;
17 try
18 {
19 var commands = Regex.Split(strFile, string.Format(@"^GO{0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline);
20 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;
30 }
31 catch (Exception ex)
32 {
33 ErrorInfo = ex;
34 return false;
35 }
36 }
37 }
38 }

  ViewVC Help
Powered by ViewVC 1.1.22