Page 1 of 1

Problem saving master/detail

Posted: Thu 06 Oct 2011 07:35
by bernd.maierhofer
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

Posted: Thu 06 Oct 2011 12:12
by AlexP
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.

Posted: Thu 06 Oct 2011 13:48
by bernd.maierhofer
... the next build, that will be available when?

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

B.

Posted: Thu 06 Oct 2011 14:43
by AlexP
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([]);

Posted: Fri 07 Oct 2011 07:57
by bernd.maierhofer
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

Posted: Fri 07 Oct 2011 08:33
by AlexP
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;

Posted: Fri 07 Oct 2011 08:52
by bernd.maierhofer
Yes, that did the trick.

tx Bernd