How to view data in a dbgrid

Asked

Viewed 729 times

2

I’m using SQLConnection, SQLDataSet, ClientDataSet, DataSetProvider, ClientDataSet and a DataSource.

I need to display the data on one dbgrid, but I’m not sure how to do that.

In the FormCreate I must open the connection by clientDataSet?

procedure TFormImportDados.FormCreate(Sender: TObject);
begin  
  CdsFB.Open;  
end;

2 answers

5


Make sure the components are configured correctly:

SQLConnection: Driver configuration and base path;

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

DatasetProvider: Property Dataset defined as SQLDataset;

ClientDataset: Property ProviderName defined as DatasetProvider;

DataSource: Property Dataset defined as ClientDataset;

DBGrid: Property DataSource defined as DataSource;

Done this just give one .Open in the Clientdataset:

ClientDataSet1.Open;

Note: I advise to give the .Open at the event FormShow

1

I don’t usually run the project with the components open... In this case I would open the connection first, then Sqldataset, and then Clientdataset. I believe there is an extra CDS there... My recommendation would be to use SQLConnection, SQLDataSet,DataSetProvider, ClientDataSet and finally the DataSource.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.