TVirtualDataSet working with tables that does not have the recno property.

Discussion of open issues, suggestions and bugs regarding Virtual Data Access Components for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
macc2010
Posts: 2
Joined: Mon 27 Jan 2020 09:39

TVirtualDataSet working with tables that does not have the recno property.

Post by macc2010 » Mon 27 Jan 2020 10:31

Hello,

I am interested in VirtualDac to virtualize the access to tables that does not have the Recno property ( for example Elevatedb ), but has the RecordCount and BookMark properties instead of Recnos.

If I set the property OnGetFieldValue of a TVirtualDataSet to a procedure for example :

procedure TfmMain.DeptDataSetGetFieldValue(Sender: TObject; Field: TField; RecNo: Integer; out Value: Variant);

The procedure pass as parameter a Recno ( that I do not have in this kind of tables ), but in this case I need a bookmark instead.

Would it possible to implement new events oriented to work with bookmarks instead of Recnos?.

Thank you.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: TVirtualDataSet working with tables that does not have the recno property.

Post by MaximG » Fri 31 Jan 2020 15:24

The event handler OnGetFieldValue in the VirtualDataSet component is designed to return data to a virtual dataset. The RecNo parameter is not related to the record number in the physical table Elevatedb or any database. According to the business logic in your application, this handler should implement the correspondence between the RecNo of the prepared dataset and some unique identifier of the dataset (for example, RecordCount or BookMark).

macc2010
Posts: 2
Joined: Mon 27 Jan 2020 09:39

Re: TVirtualDataSet working with tables that does not have the recno property.

Post by macc2010 » Wed 05 Feb 2020 00:22

Hello,

Suppose that Tb1 is the name of the elevatedb table and DeptDataSet is a TVirtualDataSet and that I do not set Filters or Ranges to the DeptDataSet table ( or any other method that would break the relation between the DeptDataSet.Recno and the Tb1.Recno ) and suppose that I have written in the procedure of response to the OnGetFieldValue event of the DeptDataSet table :

procedure TfmMain.DeptDataSetGetFieldValue(Sender: TObject; Field: TField; RecNo: Integer; out Value: Variant);
begin
Tb1.Recno:=Recno;
Value:=Tb1.FieldByName(Field.FieldName).Value;
end;

As I cannot do Tb1.Recno := Recno because Tb1 does not supports the recno property, how do I move Tb1 to the spected position?. OnGetFieldValue is oriented to work with lists, not with a sequenced list that I cannot access by its index.

Can you put an example with your suggestion?.

Thank you.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: TVirtualDataSet working with tables that does not have the recno property.

Post by MaximG » Fri 21 Feb 2020 15:57

You can find an example of using TVirtualDataSet in the Demo project, which is distributed with VirtualDAC: [VirtualDAC Demo Folder]\Demos\VirtualDataSet\

Post Reply