Reputation: 623
I have a form with a dbgrid and an sqlquery component. I am trying to fill the dbgrid with the sqlquery. When I do I get the message, "Operation not allowed on Unidirectional dataset." I do NOT want to use a client data set, as I do not want a 'local' copy of the data, I would like to read and display the data directly. How can this be done?
Upvotes: 2
Views: 7518
Reputation: 1
To use a grid you need these components ... SQLQuery DataSetProvider ClientDataSet DataSource DBGrid
Upvotes: 0
Reputation: 125757
The documentation clearly states (emphasis added):
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.
Because there's no buffering of multiple records, you can't move in any direction except forward, which means that the DBGrid
could not display multiple rows or support scrolling.
(In fact, all of the DBExpress
components are unidirectional, according to the documentation on Types of DBExpress DataSets.)
You'll have to either use a TClientDataSet
or change from using DBExpress
to some other method of accessing the data such as ADO
instead, or display the data using something other than TDBGrid
(like a TStringGrid
) and implement your own internal storage. However, TClientDataSet
doesn't have to be a disk file, if the amount of data you're retrieving is manageable in memory; all of the data can just stay there without being a "local copy" (an "in-memory dataset").
Upvotes: 10