public bool executeSQL(ConfigData cd) { Logger.logIt(cd, "DatabaseReplicaStatesRow: trying to connect to: " + cd.dataSource); SqlConnection myConnection = new SqlConnection("user id =...;password=...;Integrated Security=SSPI;Data Source=" + cd.dataSource + ";Initial Catalog=" + cd.catalog); try { myConnection.Open(); Logger.logIt(cd, "DatabaseReplicateStatesProcessor: Connection has been opened."); SqlDataReader reader = null; SqlCommand command = new SqlCommand(sqlJoin, myConnection); reader = command.ExecuteReader(); Logger.logIt(cd, "DatabaseReplicateStatesProcessor: Reading the results."); while (reader.Read()) { DatabaseReplicaStatesRow r = new DatabaseReplicaStatesRow(); r.replica_id = reader.GetGuid(0).ToString(); r.database_name = reader.GetString(1); r.is_failover_ready = reader.GetBoolean(2); r.is_pending_secondary_suspend = reader.GetBoolean(3); r.is_database_joined = reader.GetBoolean(4); r.replicaName = reader.GetString(5); rows.Add(r); Logger.logIt(cd, r.ToString()); } } catch (Exception e) { Console.WriteLine(e.Message); Logger.logIt(cd, e.Message); return(false); } return(true); }
private bool analyzeRow(ConfigData cd, DatabaseReplicaStatesRow r, in StringBuilder sb)