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: 299
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...

Post Reply