TVirtualTable.LoadFromFile() problem

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

TVirtualTable.LoadFromFile() problem

Post by Lithium™ » Thu 17 Jan 2013 06:40

Hello!
Could you help me please with TVirtualTable?

TVirtualTable has pair of methods:

Code: Select all

TVirtualTable.LoadFormFile(FileName: string; RestoreFields: boolean = TRUE);
TVirtualTable.SaveToFile(FileName: string; StoreFields: boolean = TRUE);
My form definition is:

Code: Select all

  TfrmMyForm = class(TForm)
    dstEvents: TVirtualTable;
    dstEventsSerial: TIntegerField;
    ...
  end;
I do the following:

Code: Select all

procedure TfrmMyForm.btnMyActionClick(Sender: TObject);
begin
  dstEvents.SaveToFile(dstEvents.Name + '.vtd');
  ...
  dstEvents.LoadFormFile(dstEvents.Name + '.vtd');
  ...
  dstEvents.Insert;
  // next row raises an error, because dstEventsSerial = nil
  dstEventsSerial.Value := dstEvents.RecordCount;
  dstEvents.Post;
end;
I have tried to set RestoreFields to FALSE and it works without any errors.
However, is it normal behavior when field refs are lost?

Thanks.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TVirtualTable.LoadFromFile() problem

Post by AlexP » Thu 17 Jan 2013 11:34

Hello,

This is the correct behavior. To make fields not cleared, you should set the parameter LoadFields of the LoadFromFile method to False

Post Reply