How to display data in a dbgrid

2

I'm using SQLConnection, SQLDataSet, ClientDataSet, DataSetProvider, ClientDataSet and DataSource .

I need to display the data in dbgrid , but I'm not sure how to do this.

No FormCreate should I open the connection with clientDataSet ?

procedure TFormImportDados.FormCreate(Sender: TObject);
begin  
  CdsFB.Open;  
end;
    
asked by anonymous 01.07.2016 / 14:09

2 answers

5

Make sure the components are configured correctly:

SQLConnection : Configuration of drivers and base path;

SQLDataset : With a valid SQL command, and with Connection set to SQLConnection ;

DatasetProvider : Property Dataset set to SQLDataset ;

ClientDataset : Property ProviderName set to DatasetProvider ;

DataSource : Property Dataset set to ClientDataset ;

DBGrid : Property DataSource set to DataSource ;

Just do a .Open in the ClientDataSet:

ClientDataSet1.Open;

Note: I advise you to give .Open in event FormShow

    
01.07.2016 / 15:33
1

I do not usually run the project with the components open ... In that case I would open the connection first, then the SQLDataSet, and then the ClientDataset. I believe I have an extra CDS there ... My recommendation would be to use SQLConnection, SQLDataSet,DataSetProvider, ClientDataSet , and finally DataSource .

    
02.07.2016 / 04:14