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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 119 - (hide annotations) (download)
Sat Jul 14 09:08:55 2012 UTC (8 years, 11 months ago) by william
File size: 2191 byte(s)
+ bulk commit again

1 william 85 using System;
2     using System.Collections.Generic;
3     using System.Text;
4     using System.Data.SqlClient;
5    
6     namespace AnywhereTS.DBSupport
7     {
8     public class SqlMdfConnector : DBConnector<SqlParameter, SqlCommand, SqlConnection, SqlDataAdapter>
9     {
10     public SqlMdfConnector(string DBServerAddress, string DBServerInstance, string SqlMdf) : base(DBServerAddress, DBServerInstance, SqlMdf) { }
11    
12     public override void CreateConnection(out Exception ErrorInfo)
13     {
14     ErrorInfo = null;
15     try
16     {
17     string connetionString = null;
18 william 89 connetionString = GetConnectionString();
19 william 85 connection = new SqlConnection();
20     connection.ConnectionString = connetionString;
21     }
22     //catch (SqlException ex) { Console.WriteLine(ex.ToString()); ErrorInfo = ex; throw ErrorInfo;}
23     catch (Exception ex) { Console.WriteLine(ex.ToString()); ErrorInfo = ex; throw ErrorInfo; }
24     }
25 william 89
26     new public static string GetConnectionString()
27     {
28 william 119 return string.Format(@"Data Source={0}\{1};AttachDbFilename=|DataDirectory|\{2};Integrated Security=SSPI", DBServerAddress, DBServerInstance, DBDatabase);
29 william 89 }
30 william 119
31     public override bool ClientRunScript(string[] strCommands, out Exception ErrorInfo)
32     {
33     ErrorInfo = null;
34     try
35     {
36     foreach (string strCmd in strCommands)
37     {
38     if (strCmd.Length > 0)
39     {
40     Logging.DatabaseLog.DebugFormat("Current Command: {0}{1}", System.Environment.NewLine, strCmd);
41     // Substitute database directory with the decided one.
42     SqlCommand command = this.CreateCommandInstance(strCmd, new List<SqlParameter>(), out ErrorInfo);
43     command.ExecuteNonQuery();
44     }
45     }
46     return true;
47     }
48     catch (Exception ex)
49     {
50     ErrorInfo = ex;
51     return false;
52     }
53     }
54 william 85 }
55     }

  ViewVC Help
Powered by ViewVC 1.1.22