/// <summary> /// A method called when the execution of the database query succeeded and the data is raw. /// </summary> /// <param name="server">The database server.</param> /// <param name="result">The result data.</param> /// <param name="recordsAffected">The number of records affected.</param> protected virtual void OnQuerySucceeded(DbServerSql server, DbQuerySql query, DbDataRaw result, int recordsAffected) { }
/// <summary> /// An event handler called when the database query completed successfully and the resulting data is raw /// data. /// </summary> /// <param name="server">The database server.</param> /// <param name="query">The database query.</param> /// <param name="result">The database result.</param> /// <param name="recordsAffected">The number of records read.</param> private void DatabaseQuerySuccess(DbServerSql server, DbQuerySql query, DbDataRaw result, int recordsAffected) { // Execute the code on the UI thread. this.Invoke(() => { this.OnQuerySucceeded(server, query, result, recordsAffected); }); }
/// <summary> /// An event handler called when the query completed successfully. /// </summary> /// <param name="table">The data table.</param> /// <param name="recordsAffected">The number of records affected by the query.</param> private void OnQuerySuccess(DbDataRaw table, int recordsAffected) { // Execute the code on the UI thread. this.Invoke(() => { // Enable the start button. this.buttonStart.Enabled = true; // Disable the stop button. this.buttonStop.Enabled = false; // Disable the query code box. this.codeBox.Enabled = true; // Display the table data. // If the table has any data. if (table.HasData) { // Add the table columns. foreach (string column in table.ColumnNames) { this.dataGrid.Columns.Add(column, column); } // Add the table rows. for (int row = 0; row < table.RowCount; row++) { this.dataGrid.Rows.Add(table.GetRow(row)); } // Update the status box. this.statusLabel.Text = "Query completed successfully: {0} row{1} of data fetched.".FormatWith(table.RowCount.ToString(), table.RowCount.PluralSuffix()); } else { if (recordsAffected >= 0) this.statusLabel.Text = "Query completed successfully: {0} data records changed.".FormatWith(recordsAffected); else this.statusLabel.Text = "Query completed successfully."; } this.statusLabel.Image = Resources.Success_16; }); }