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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 134 - (hide annotations) (download)
Sun Jul 15 05:13:20 2012 UTC (8 years, 9 months ago) by william
File size: 1577 byte(s)
+ fix errors in database
+ logon to 'master' database and refer to our database is sql statments
+ remove empty GO statements from end of .sql files

1 william 85 using System;
2     using System.Collections.Generic;
3     using System.Text;
4     using System.Data.SqlClient;
5 william 125 using System.Linq;
6     using System.Text.RegularExpressions;
7 william 85 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 william 119
13 william 123
14     protected override bool ClientRunScript(string strFile, out Exception ErrorInfo)
15 william 119 {
16     ErrorInfo = null;
17     try
18     {
19 william 129 var commands = Regex.Split(strFile, string.Format(@"^GO{0}", System.Environment.NewLine), RegexOptions.IgnoreCase | RegexOptions.Multiline);
20 william 125 foreach (var command in commands)
21     {
22 william 129 Logging.DatabaseLog.DebugFormat("Current Command={0}", command);
23 william 134 SqlConnection sqlCon;
24     this.GetConnectionClone(out sqlCon,out ErrorInfo);
25 william 130 SqlCommand sqlcmd = new SqlCommand(command, this.connection);
26 william 134 sqlcmd.CommandText = command;
27     sqlcmd.Connection = sqlCon;
28 william 128 sqlcmd.CommandType = System.Data.CommandType.Text;
29 william 125 sqlcmd.ExecuteNonQuery();
30     }
31 william 119 return true;
32     }
33     catch (Exception ex)
34     {
35     ErrorInfo = ex;
36 william 131 throw ErrorInfo;
37 william 119 }
38     }
39 william 85 }
40     }

  ViewVC Help
Powered by ViewVC 1.1.22