Page 1 of 1

next and prior record ID without moving dataset cursor

Posted: Sun 17 Feb 2013 01:47
by inageib
Hi,
I am using FireBird and I wonder if there is a method or function can get the next or prior ID of the current record without moving the dataset cursor ?

Thanks

Re: next and prior record ID without moving dataset cursor

Posted: Mon 18 Feb 2013 11:41
by AndreyZ
Hello,

The TDataSet component (which all dataset components are based on) does not have such functionality. You can write about this feature to the Embarcadero support.
As a solution, you can use the Next and Prior methods of the TDataSet component. To prevent visual database components of updating, you should call the DisableControls method before changing the current record, and call the EnableControls method after the job is done. Here is a code example:

Code: Select all

var
  nextID: integer;
begin
  IBCQuery1.DisableControls;
  IBCQuery1.Next;
  nextID := IBCQuery1.FieldByName('id').AsInteger;
  IBCQuery1.Prior;
  IBCQuery1.EnableControls;
  ShowMessage(IntToStr(nextID));
end;

Re: next and prior record ID without moving dataset cursor

Posted: Mon 18 Feb 2013 17:02
by inageib
Thanks Andrey

Re: next and prior record ID without moving dataset cursor

Posted: Tue 19 Feb 2013 08:42
by AndreyZ
Glad to help. If any other questions come up, please contact us.