/// <summary> /// Configure a ConnectionString that has been entered manually. /// </summary> /// <remarks> /// Please note that we currently assume that the 'System.Data.SqlClient' provider can be used. /// </remarks> /// <param name="connectionString"></param> public void ConfigureDatabaseConnection(string connectionString) { var provider = DbConnectionExtensions.DetectProviderFromConnectionString(connectionString); var databaseProvider = provider.ToString(); var providerName = Constants.DatabaseProviders.SqlServer; if (databaseProvider.ToLower().Contains("mysql")) { providerName = Constants.DatabaseProviders.MySql; } SaveConnectionString(connectionString, providerName); Initialize(string.Empty); }
/// <summary> /// Configure a ConnectionString that has been entered manually. /// </summary> /// <remarks> /// Please note that we currently assume that the 'System.Data.SqlClient' provider can be used. /// </remarks> /// <param name="connectionString"></param> public void ConfigureDatabaseConnection(string connectionString) { var provider = DbConnectionExtensions.DetectProviderFromConnectionString(connectionString); var databaseProvider = provider.ToString(); var providerName = "System.Data.SqlClient"; if (databaseProvider.ToLower().Contains("mysql")) { providerName = "MySql.Data.MySqlClient"; } SaveConnectionString(connectionString, providerName); Initialize(string.Empty); }
internal bool CheckConnection(DatabaseModel database, ApplicationContext applicationContext) { string connectionString; DatabaseProviders provider; var dbContext = applicationContext.DatabaseContext; if (database.ConnectionString.IsNullOrWhiteSpace() == false) { connectionString = database.ConnectionString; provider = DbConnectionExtensions.DetectProviderFromConnectionString(connectionString); } else if (database.DatabaseType == DatabaseType.SqlCe) { //we do not test this connection return(true); //connectionString = dbContext.GetEmbeddedDatabaseConnectionString(); } else if (database.IntegratedAuth) { connectionString = dbContext.GetIntegratedSecurityDatabaseConnectionString( database.Server, database.DatabaseName); provider = DatabaseProviders.SqlServer;; } else { string providerName; connectionString = dbContext.GetDatabaseConnectionString( database.Server, database.DatabaseName, database.Login, database.Password, database.DatabaseType.ToString(), out providerName); provider = database.DatabaseType == DatabaseType.MySql ? DatabaseProviders.MySql : DatabaseProviders.SqlServer; } return(DbConnectionExtensions.IsConnectionAvailable(connectionString, provider)); }