예제 #1
0
        private static DbConnection GetConnectionString(ConfigUtil.ConfigData config)
        {
            DbConnection connection;

            if (config == null || config.Sqlite)
            {
                var sqlitecn = new SQLiteConnectionStringBuilder();

                sqlitecn.DataSource    = dbpath;
                sqlitecn.FailIfMissing = false;
                //sqlitecn.FailIfMissing = false;
                connection = new SQLiteConnection()
                {
                    ConnectionString = sqlitecn.ConnectionString
                };
            }
            else
            {
                var sqlcn = new SqlConnectionStringBuilder();
                sqlcn.DataSource = config.MySQLServer;
                sqlcn.UserID     = config.UserID;
                sqlcn.Password   = config.Password;
                connection       = new SqlConnection()
                {
                    ConnectionString = sqlcn.ConnectionString
                };
            }

            return(connection);
        }
예제 #2
0
 public void SetConnectionStringParameters(ConfigUtil.ConfigData config)
 {
     connectionStringBuilder.Server   = config.MySQLServer;
     connectionStringBuilder.Database = config.Database;
     connectionStringBuilder.UserID   = config.UserID;
     connectionStringBuilder.Password = config.Password;
 }
예제 #3
0
 public DatabaseLink(ConfigUtil.ConfigData config) : base(GetConnectionString(config), true)
 {
 }
예제 #4
0
 public DatabaseLink(ConfigUtil.ConfigData config)
 {
     SetConnectionStringParameters(config);
 }