Problem saving master/detail

Discussion of open issues, suggestions and bugs regarding Virtual Data Access Components for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bernd.maierhofer
Posts: 4
Joined: Thu 06 Oct 2011 06:08
Contact:

Problem saving master/detail

Post by bernd.maierhofer » Thu 06 Oct 2011 07:35

Hi and tx for any answer.

using VT 8 I have a master table and a detail table. At runtime I add date to both tables, this works ok, as my grids only show thje detail records. However, when I want to save the data to a file via SaveToFile only the detail records for the active rec are saved.

What am I missing?

tx Bernd

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

Post by AlexP » Thu 06 Oct 2011 12:12

Hello,

At the moment you will not be able to save all inserted data into Client VirtualTable. We've fixed this behaviour and this fix will be included in the next build.

bernd.maierhofer
Posts: 4
Joined: Thu 06 Oct 2011 06:08
Contact:

Post by bernd.maierhofer » Thu 06 Oct 2011 13:48

... the next build, that will be available when?

Is it possible to get a quick (just code) fix in advance?

B.

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

Post by AlexP » Thu 06 Oct 2011 14:43

Hello,

The next build will be available next week. For the time being you can fix this problem by making the following changes in the MemDS.pas file:

add the following code to the TMemDataSet.MDPropertiesChanged method:

Code: Select all

  if Data  nil then
    Data.FilterUpdated;
  if Active then
    Resync([]);

bernd.maierhofer
Posts: 4
Joined: Thu 06 Oct 2011 06:08
Contact:

Post by bernd.maierhofer » Fri 07 Oct 2011 07:57

No, this does not fix the problem.

Code: Select all

vt1.SaveToFile('vt1.vtd',true);
vt2.SaveToFile('vt2.vtd',true);
vt1.close;
vt2.close;
vt1.open;
vt2.open;
vt1.LoadFromFile('vt1.vtd',true);
vt2.LoadFromFile('vt2.vtd',true);
vt2 still only holds data for one record from vt1

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

Post by AlexP » Fri 07 Oct 2011 08:33

Hello,

The SaveToFile method saves data that is in DataSet at the moment, and as Detail DataSet contains only records that correspond to the current record in Master Dataset. You need to set the MasterSource property to nil beforehand in order to save all your records:

var
TempDataSource: TDataSource;
begin
TempDataSource:= DetailVirtualTable.MasterSource;
DetailVirtualTable.MasterSource:= nil;
DetailVirtualTable.SaveToFile('d:\1.bak');
DetailVirtualTable.MasterSource:= TempDataSource;

bernd.maierhofer
Posts: 4
Joined: Thu 06 Oct 2011 06:08
Contact:

Post by bernd.maierhofer » Fri 07 Oct 2011 08:52

Yes, that did the trick.

tx Bernd

Post Reply