Why doesn't setting the RecNo property of the table move to this record?

I have a TTable component that uses BDE to access a DBase table. There is no index in the table, so the sort order is the physical order of the entries in the table. If I read the RecNo property, it contains the expected number for the current record.

I got the impression that with this constellation (BDE + DBase), you can also set the RecNo property to go to the corresponding record. But apparently this does not work in my program.

So: Do ​​I remember this wrong? Or is there something special I need to do for this?

(Please do not report the abandonment of BDE. I know about its problems, and we are already leaving it.)

+6
source share
1 answer

TBDEDataSet implements the RecNo installer only for Paradox (not DBase ).

 unit DBTables; ... procedure TBDEDataSet.SetRecNo(Value: Integer); begin CheckBrowseMode; if (FRecNoStatus = rnParadox) and (Value <> RecNo) then begin DoBeforeScroll; if DbiSetToSeqNo(Handle, Value) = DBIERR_NONE then begin Resync([rmCenter]); DoAfterScroll; end; end; end; 

You might want to try something in common:

 procedure SetRecNo(DataSet: TDataSet; const RecNo: Integer); var ActiveRecNo, Distance: Integer; begin if (RecNo > 0) then begin ActiveRecNo := DataSet.RecNo; if (RecNo <> ActiveRecNo) then begin DataSet.DisableControls; try Distance := RecNo - ActiveRecNo; DataSet.MoveBy(Distance); finally DataSet.EnableControls; end; end; end; end; 
+8
source

Source: https://habr.com/ru/post/912316/


All Articles