Delphi Examples: DbiSetToRecordNo

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiSetToRecordNo

Return to chapter overview

Position the cursor to the given physical record number.

Valid only for dBASE and FoxPro tables. The function fDbiSetToRecordNo, below, positions the cursor in the TTable specified in the Tbl parameter to the record number specified in RecordNum. Call the TTable component’s Resync method after repositioning the record pointer with DbiSetToRecordNo to synchronize the TTable with the underlying dataset.

This example uses the following input:

 fDbiSetToRecordNum(DBASEANIMALS, 20);

 

The procedure is:

procedure fDbiSetToRecordNo(Tbl: TTable; RecordNum: LongInt);

var

 rslt: dbiResult;

begin

 rslt:= DbiSetToRecordNo(Tbl.handle, RecordNum);

if (rslt <> DBIERR_NONE) then begin

  if (rslt = DBIERR_EOF) then

     tbl.last;

  if (rslt = DBIERR_BOF) then

     tbl.first;

end;

 Tbl.Resync([]);

end;