/ Home / HowTo / LoadProvince

The ProvinceSQLManager class is a strongly typed manager class specifically for use with the Province table and Province Data Object.

using LJCDataGridLib;
using LJCNetCommon;
using LJCWinFormControls;
using System.Data;

// Populate a grid with data.
internal void LoadManager(LJCDataGrid ljcGrid, string connectionString
  , string providerName)
{
  var manager = new ProvinceSQLManager(null, null, connectionString
    , providerName);

  // Create grid columns.
  var gridColumns = manager.BaseDefinition.Clone();
  gridColumns.LJCRemoveColumn("ID");
  ljcGrid.LJCAddColumns(gridColumns);

  // Add data to the grid.
  var propertyNames = gridColumns.LJCGetPropertyNames();
  var dataTable = manager.LoadDataTable(propertyNames: propertyNames);
  if (NetCommon.HasData(dataTable))
  {
    // Create and load the grid rows individually.
    foreach (DataRow dataRow in dataTable.Rows)
    {
      var ljcGridRow = ljcGrid.LJCRowAdd();
      TableData.RowSetValues(ljcGridRow, dataRow);
    }
  }
}
/ Home / HowTo / LoadProvince

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.