static public Result <bool> DatabaseExists(string connectionString) { try { var provider = new SqlServerProvider(connectionString); return(Result <bool> .Ok(provider.DatabaseExists())); } catch (Exception ex) { return(Result <bool> .Error(ex)); } }
private async Task <Result> ValidateSqlConnectionAsync() { if (String.IsNullOrEmpty(SqlConnectionString)) { return(Result.Error("Empty connection string", "Please, enter a valid connection string.")); } try { var cnn = new SqlConnection(SqlConnectionString); } catch { return(Result.Error("Bad connection string", "Please, enter a valid connection string.")); } try { IsSqlBusy = true; using (var cnn = new SqlConnection(SqlConnectionString)) { await cnn.OpenAsync(); } var provider = new SqlServerProvider(SqlConnectionString); if (provider.DatabaseExists()) { if (provider.IsLastVersion()) { return(Result.Ok("Success", "The connection to the Sql Server succeeded.")); } return(Result.Error("Version mismatch", "Database version mismatch. Please, press the 'Create' button and try again.")); } else { return(Result.Error("Database not found", "Database not found using current connection string. Please, press the 'Create' button and try again.")); } } catch (Exception ex) { return(Result.Error("Error connecting to Sql Server", ex.Message)); } finally { IsSqlBusy = false; } }
public Result IsAvailable() { try { var provider = new SqlServerProvider(ConnectionString); if (provider.DatabaseExists()) { if (provider.IsLastVersion()) { return(Result.Ok()); } return(Result.Error("Version mismatch", "Database version mismatch. Please, press the 'Create' button and try again.")); } return(Result.Error("Database not found", "Database not found using current connection string. Please, press the 'Create' button and try again.")); } catch (Exception ex) { return(Result.Error(ex)); } }