public static DBViewDataTable ExecuteQuery(DbConnection dbConnection, string query)
 {
     var dbCommand = dbConnection.CreateCommand();
     dbCommand.CommandText = query;
     DbDataReader reader = null;
     var dbViewDataTable = new DBViewDataTable();
     try
     {
         reader = dbCommand.ExecuteReader();
         dbViewDataTable.DataTable.Load(reader, LoadOption.OverwriteChanges);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         if (reader != null)
         {
             reader.Close();
             dbViewDataTable.RecordsAffected = reader.RecordsAffected;
         }
     }
     return dbViewDataTable;
 }
 private void SetQueryStatusLabel(DBViewDataTable dbViewDataTable)
 {
     queryStatusLabel.Text = string.Empty;
     if (dbViewDataTable.RecordsAffected >= 0 && queryDataGrid.RowCount == 0)
         queryStatusLabel.Text = "Number of rows updated: " + dbViewDataTable.RecordsAffected;
     else queryStatusLabel.Text = "Number of records: " + queryDataGrid.RowCount;
 }
 public QueryEventArgs(DBViewDataTable dbViewDataTable)
 {
     this.dbViewDataTable = dbViewDataTable;
 }