Delphi DBGrid not showing data

Viktor Anastasov picture Viktor Anastasov · Mar 26, 2014 · Viewed 9.4k times · Source

I have a delphi form with TFDConnection, TFDQuery, TDataSource and TDBGrid. I want to show the data that my query gets (select * from table_1) and put it in my DBGrid. I've made all the connections between the components, but after I launch my query (which returns 12 rows) in my DBGrid are shown 12 rows but they are empty. Apparentely I forgot something that prevents me from seeing my data in my DBGrid. Can you help me what I'm missing in my actions ?

  • 1- Adding all components to the form.
  • 2- Connect FDQuery with FDConnection, TDataSource with FDQuery, DBGrid with TDataSource.
  • 3- Connection parameters succed in testing (the problem is not in my connection parameters)
  • 4- The number of rows are placed in my DBGrid (12), but with no information visible.
  • 5- If I loop through my FDQuery I can see all the information I need but that doesn't help me populate my DBGrid.

Answer

A_R picture A_R · Oct 31, 2014

Can you try this:

Make your TFDQuery active explicitly in your OnShow code of your Form. Like this,

procedure TForm.FormShow(Sender: TObject);
begin
    FDQuery.Active:= True;
end;

It works for me and hope it helps.