private DatabaseCredentials GetDatabaseCredentialsFromSettings() { DatabaseCredentials databaseCredentials = new DatabaseCredentials() { Database = this.DefaultSettings["Initial Catalog"], Password = this.DefaultSettings["Password"], Server = this.DefaultSettings["Data Source"], UserId = this.DefaultSettings["User Id"] }; return databaseCredentials; }
public static DatabaseCredentials Parse(string connectionString) { DatabaseCredentials credentials = new DatabaseCredentials(); string[] configs = connectionString.Split(';'); foreach (string config in configs) { string[] keyValue = config.Split('='); if (keyValue[0].Equals("server", StringComparison.OrdinalIgnoreCase)) credentials.Server = keyValue[1]; else if (keyValue[0].Equals("database", StringComparison.OrdinalIgnoreCase)) credentials.Database = keyValue[1]; else if (keyValue[0].Equals("user id", StringComparison.OrdinalIgnoreCase)) credentials.UserId = keyValue[1]; else if (keyValue[0].Equals("password", StringComparison.OrdinalIgnoreCase)) credentials.Password = keyValue[1]; else if (keyValue[0].Equals("initial catalog", StringComparison.OrdinalIgnoreCase)) credentials.Database = keyValue[1]; else if (keyValue[0].Equals("data source", StringComparison.OrdinalIgnoreCase)) credentials.Server = keyValue[1]; } return credentials; }
public SQLServerGatherer(string connectionString) { this.Credentials = Parse(connectionString); this.SqlServer = new Data.SqlServer(connectionString); }
public SQLServerGatherer(DatabaseCredentials credentials) { this.Credentials = credentials; this.SqlServer = new Data.SqlServer(this.Credentials.ToSqlServerConnectionString()); }