process all records in sorted dataset

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

process all records in sorted dataset

Post by Ludek » Mon 07 Jun 2021 13:16

Hi, do you have a recommended way to process all records in sorted dataset? Especially how to handle the situation, when the field, that is included in indexfieldnames, has to be changed.

typically, such code does not process the whole dataset, but only the (initially) first record - because with the first ".post" it jumps to last position (because of active sorting) and the next ".next" call activates eof and the iterations stops.

Code: Select all

dataset.indexfieldnames := 'somefield';
dataset.first;
while not dataset.eof do begin
  dataset.edit;
  datasetsomefield.asinteger := maxint;
  dataset.post;
  dataset.next;
end;
Thanks for ideas. I have the only one - set indexfieldnames before this iteration to empty string, but i don't find this nice...

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: process all records in sorted dataset

Post by Stellar » Thu 12 Aug 2021 07:12

Hi there,

When the data in the locally sorted dataset is changed the recordset is automatically sorted.
To solve this issue, you may sort data on server, or make changes on the server, and then update the dataset.

Regards,
Sergey

Post Reply