Mason Wheeler
Mason Wheeler

Reputation: 84650

How do I retrieve all records through a TDatasetProvider?

If I have two datasets that are both descended from TCustomClientDataset, I can have one call CloneCursor on the other, and have an independent view of the same data. The documentation makes it appear that you can achieve essentially the same thing by using a TDatasetProvider, except that the source dataset can be any dataset.

I'm trying to make this work. I have a TSimpleDataset (let's call it A) that reads data from a database, and a TClientDataset (let's call it B) that works with a separate view of it, and there's a TDBGrid connected to B.

If I call B.CloneCursor(A, ...), the grid displays all the records in A. But if I create a TDatasetProvider and set its Dataset property to A, and then set it as the provider for B, the grid connected to B only displays one row, instead of all of them.

What am I doing wrong, and how do I fix it so that the grid will end up displaying all of A?

Upvotes: 1

Views: 865

Answers (1)

Mason Wheeler
Mason Wheeler

Reputation: 84650

After a lot of poking around in the debugger, I managed to track this down. Opening the dataset pulls data through the provider, but it does not call First on the source dataset first. Because of something elsewhere in the program, the source dataset had been on the last row, so I only got one row before it hit EOF. Explicitly calling First beforehand fixes the problem.

Upvotes: 1

Related Questions