Delphi - DBGrid 不显示 ADO 的内容 Table
Delphi - DBGrid doesn't display contents of ADO Table
所以我尝试在 运行 时将我所有的 ADO 表加载到它们各自的 DBGrid 中。我没有收到任何错误,但网格中没有显示任何内容?我在这里做错了什么?
我使用的代码:
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;
在此先感谢您的帮助!
亲切的问候
PrimeBeat
试试这个:
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;
所以我尝试在 运行 时将我所有的 ADO 表加载到它们各自的 DBGrid 中。我没有收到任何错误,但网格中没有显示任何内容?我在这里做错了什么?
我使用的代码:
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;
在此先感谢您的帮助!
亲切的问候 PrimeBeat
试试这个:
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;