Changeset 8 for Common/Database.cs


Ignore:
Timestamp:
Aug 12, 2019, 12:33:47 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Updated files.
  • Added: ExtTools class for external program and compare tool execution.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/Database.cs

    r7 r8  
    2828        public delegate void LogMessageHandler(string text);
    2929        public static event LogMessageHandler LogMessage;
    30         public static string connectionString = "";
    3130        public static string databaseName = "";
    3231        public static string serverName = "";
     
    4039
    4140            // Connect to server
    42             if (type == DatabaseType.MsSql)
    43             {
    44                 connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";
    45             } else
    4641            if (type == DatabaseType.SQLite)
    4742            {
    4843                Directory.CreateDirectory(Path.GetDirectoryName(sqliteFileName));
    49                 connectionString = "Data Source=" + sqliteFileName + "; Version=3";
    5044                databaseName = null;
    5145            }
     
    6256                    {
    6357                        // database does not exist, try to create it
    64                         connectionString = "server=" + serverName + "; Trusted_Connection=yes; connection timeout=5";
    6558                        ExecuteNonQuery("CREATE DATABASE " + databaseName);
    6659
    6760                        // Need to wait for the new DB startup in order to continue and be sure it can be accessed
    6861                        if (connection is SqlConnection) SqlConnection.ClearAllPools();
    69 
    70                         connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";
    7162                    }
    7263                    else
     
    8778
    8879            return result;
     80        }
     81
     82        public static string GetConnectionString()
     83        {
     84            string connectionString = "";
     85            if (type == DatabaseType.MsSql)
     86            {
     87                connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";
     88            }
     89            else
     90            if (type == DatabaseType.SQLite)
     91            {
     92                connectionString = "Data Source=" + sqliteFileName + "; Version=3";
     93            }
     94            return connectionString;
    8995        }
    9096
     
    105111        {
    106112            DbConnection connection = GetFactory().CreateConnection();
    107             connection.ConnectionString = connectionString;
     113            connection.ConnectionString = GetConnectionString();
    108114            return connection;
    109115        }
Note: See TracChangeset for help on using the changeset viewer.