next and prior record ID without moving dataset cursor

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
inageib
Posts: 184
Joined: Wed 26 Aug 2009 14:11

next and prior record ID without moving dataset cursor

Post by inageib » Sun 17 Feb 2013 01:47

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

AndreyZ

Re: next and prior record ID without moving dataset cursor

Post by AndreyZ » Mon 18 Feb 2013 11:41

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;

inageib
Posts: 184
Joined: Wed 26 Aug 2009 14:11

Re: next and prior record ID without moving dataset cursor

Post by inageib » Mon 18 Feb 2013 17:02

Thanks Andrey

AndreyZ

Re: next and prior record ID without moving dataset cursor

Post by AndreyZ » Tue 19 Feb 2013 08:42

Glad to help. If any other questions come up, please contact us.

Post Reply