Created
February 23, 2021 09:14
-
-
Save amarodeabreu/646abba49e3b67b0534823027b67eb6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Get database tables to populate grid | |
/// </summary> | |
private void GetTables() | |
{ | |
// Get all SQL tables for the db defined in the settings file | |
var sql = "SELECT TABLE_NAME As Tables FROM " + Properties.Settings.Default.Database + ".INFORMATION_SCHEMA.TABLES with (nolock) WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME ASC"; | |
try | |
{ | |
var dtDatatable = QueryDatabase(ConnectionString, sql).Tables[0]; | |
gridView1.Columns.Clear(); | |
tablesGrid.DataSource = null; | |
tablesGrid.DataSource = dtDatatable; | |
gridView1.BestFitColumns(); | |
tablesGrid.RefreshDataSource(); | |
gridView3.Columns.Clear(); | |
gridControl1.DataSource = null; | |
gridControl1.DataSource = dtDatatable; | |
gridView3.BestFitColumns(); | |
gridControl1.RefreshDataSource(); | |
} | |
catch (Exception ex) | |
{ | |
// Show alert on error - no message boxes, using popups | |
var alertInfo = new AlertInfo("Error", ex.Message); | |
var control = new AlertControl { FormLocation = AlertFormLocation.BottomRight }; | |
control.Show(ParentForm, alertInfo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment