/// <summary> /// This method does the actual comparison; it is called by the RemoteCompare and the normal comparison /// </summary> private void CompareDatabaseStructure(Database sourceDatabase, Database targetDatabase) { // local SchemaComparison schemaComparison = new SchemaComparison(); // verify both objects exist if (NullHelper.Exists(sourceDatabase, targetDatabase)) { // test if any data was loaded before showing 'The target database is up to date message incorrectly' if (sourceDatabase.Tables.Count > 0) { // Get the value for IgnoreDiagramProcedures bool ignoreDiagramProcedures = this.IgnoreDiagramProceduresCheckBox.Checked; // Create a new database comparer DatabaseComparer comparer = new DatabaseComparer(sourceDatabase, targetDatabase, ignoreDiagramProcedures); // Compare the two database schemas schemaComparison = comparer.Compare(); } else { // Add this as a message schemaComparison.SchemaDifferences.Add("The source database does not contain any tables; the comparison cannot continue."); } // compare the two schemas if (schemaComparison != null) { // if the two database are equal if (schemaComparison.IsEqual) { // Show the two databases are equal this.ResultsTextBox.Text = "The target database is up to date."; } else { // Display the count this.CountLabel.Text = "Count: " + schemaComparison.SchemaDifferences.Count; // Create a string builder StringBuilder sb = new StringBuilder("The target database is not valid."); // Append a new line sb.Append(Environment.NewLine); // iterate the errors foreach (string schemaDifference in schemaComparison.SchemaDifferences) { // Append an indention sb.Append(" "); sb.Append(schemaDifference); sb.Append(Environment.NewLine); } // Show the schema differences this.ResultsTextBox.Text = sb.ToString(); // This is a stub for an update for Version 3.0 that isn't ready to be released //// create a message for how to //message = "Would you like to attempt to fix any errors if possible?"; //// Get the users response //DialogResult result = MessageBoxHelper.GetUserResponse(message, "Fix Schema Differences?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); //// if the user choose yes //if (result == DialogResult.Yes) //{ // // attempt to fix any schema differences // int fixedCount = SqlUpdater.FixSchemaDifferences(schemaComparison.SchemaDifferences, targetDatabaseConnector, sourceDatabase); //} } } } else if (NullHelper.IsNull(sourceDatabase)) { // Show the user a message this.ResultsTextBox.Text = "The source database could not be loaded."; } else if (NullHelper.IsNull(targetDatabase)) { // Show the user a message this.ResultsTextBox.Text = "The target database could not be loaded."; } }