Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBgrid problem

Status
Not open for further replies.

bobbygm

Programmer
Mar 30, 2005
19
IT
Hi!

I've placed a sqlQuery, a DataSource, and a DBgrid component on a Delphi7 form. The DBgrid points to the DataSource, which in turn points to the sqlQuery. When I run the application, it gives the following error: "Operation not allowed on an unidirectional dataset". What happens? How con I solve the problem?

Thank u,

Emanuele
 
The D7 Help for TSQLQuery says:
TSQLQuery is a unidirectional dataset. Unlike other datasets, unidirectional datasets do not buffer multiple records in memory. Because of this, you can only navigate using the First and Next methods. There is no built-in editing support: you can only edit the data in an SQL query by explicitly creating an SQL UPDATE command or by connecting the dataset to a client dataset using a provider. Features that require buffering multiple records, such as filters or lookup fields, are not available.
A DBGrid needs a buffer of records in order to refresh the data in the grid.

If you connect your TDataSoource to a TClientDataSet to your TSQLQuery by means of a TDataSetProvider then you get the effect you want.

Take a look at the FAQs on dbExpress.

Andrew
Hampshire, UK
 
Dear towerbase,

thank you for your advices. I also checked the dbexpress
topic in FAQS. I've added the components you named to the form, and linked them in the proper way. Now, the program doesn't give errors anymore. Still, records in the dbgrid are not displayed. I verified that the connection to the db is ok, and the SQLquery opens without problems. What's happening? What's missing?
Thank u,

Emanuele
 
Have you checked that:

the Connected property of the TSQLConnection is true ?

the Active property of the TSQLDataset is true

the Dataset property of the TDatasetProvider is set to the TSQLDataset

the ProviderName property of the TClientDataset is set to the TDatasetProvider

the Active property of the TClientDataset is set to true

the Dataset property of the TDataSource is set to the TClientDataset

the Datasource property of the TDBGrid is set to the TDatasource

You should be able to do all these at Design time and the data should appear in the DBGrid without actually running your application.

Andrew
Hampshire, UK
 
the active property of the Tclientdataset wasn't set
to true!

Now everything is ok.

Thank you very much, you were of great aid to me.

Emanuele
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top