Search code examples
delphiadodbgrid

Delphi - DBGrid doesn't display contents of ADO Table


So I've tried to load all my ADO Tables into their respective DBGrids at run-time. I get no errors but nothing displays in the Grids? What am I doing wrong here?

Code I'm using:

procedure TfrmEntry.FormActivate(Sender: TObject);
begin
  GridSetupContainer;
end;

procedure TfrmEntry.GridSetupContainer;
begin

  with dmArchive do
  begin
    GridSetup(dbgA16,dsr1660);
    GridSetup(dbgA2P1,dsrTwoPointOne);
    GridSetup(dbgAXKarts,dsrXKarts);
    GridSetup(dbgAHM,dsrHeavyMetals);
    GridSetup(dbgAHR,dsrHotrods);
    GridSetup(dbgAMIDA,dsrMidA);
    GridSetup(dbgAMIDB,dsrMidB);
    GridSetup(dbgAMinis,dsrMinis);
    GridSetup(dbgAPink,dsrPinkrods);
    GridSetup(dbgASpr,dsrSprints);
    GridSetup(dbgASR,dsrStockrods);
    GridSetup(dbgADev,dsrDev);
    GridSetup(dbgAV8,dsrV8);
    GridSetup(dbgALM,dsrLateModels);
  end;

  with dmRacers do
  begin
    GridSetup(dbgR16,dsr1660);
    GridSetup(dbgR2P1,dsrTwoPointOne);
    GridSetup(dbgRXKarts,dsrXKarts);
    GridSetup(dbgRHM,dsrHeavyMetals);
    GridSetup(dbgRHR,dsrHotrods);
    GridSetup(dbgRMIDA,dsrMidA);
    GridSetup(dbgRMIDB,dsrMidB);
    GridSetup(dbgRMini,dsrMinis);
    GridSetup(dbgRPink,dsrPinkrods);
    GridSetup(dbgRSP,dsrSprints);
    GridSetup(dbgRSR,dsrStockrods);
    GridSetup(dbgRDev,dsrDev);
    GridSetup(dbgRV8,dsrV8);
    GridSetup(dbgRLM,dsrLateModels);
  end;

end;

procedure TfrmEntry.GridSetup(grid: TDBGrid; source: TDataSource);
begin
  grid.DataSource:=source;
end;

Thanks in advance for the help!

Kind Regards PrimeBeat


Solution

  • try this:

    procedure TfrmEntry.GridSetup(grid: TDBGrid; source: TDataSource);
    begin
      grid.DataSource:=source;
      source.dataset.open; //this line!!! perhaps you don't open the table!, edited has sugested by Peter Wolf
    end;