TVirtualTable LoadFromFile preventing structure from beeing
Posted: Mon 16 Nov 2009 17:34
Hi,
I am using code like the following when setting data to a record of a tvirtualtable:
VTTest.Clear; //remove old data
VTTest.Edit;
VTTestI_FIELD1.AsInteger := 100; // dummy kto#
VTTestC_FIELD2.Value := '100'; // dummy kto#
VTTest.Post;
somewhat later I do:
fname := ExtractFileDir(Application.ExeName) + '\Data2.xml';
if FileExists(fname) then VTTest.LoadFromFile(fname);
when I repeat now
VTTest.Clear;
VTTest.Edit;
VTTestI_FIELD1.AsInteger := 100; // dummy kto#
VTTestC_FIELD2.Value := '100'; // dummy kto#
VTTest.Post;
I get an exception in the line after setting editmode maybe because the fielddefs have changed. In fact they are the same (at least similar) as bevor .loadfromfile as the xml which I use in the IDE and while running the programm are nearly the same. They differ solely in data1.xml has no data in it but the data2.xml has. Fielddefs are the same in both xml-files.
My question is. Is it like I think it is
and what can I do to simply push data to the record without destroing/recreating the structure. I have tried to solely load the data part of the xml-file but that is not working, or at least I don't know how. As it is more than 80 fields to fill up I would like a solution where I can "load" data instead of coding it by hand.
Thanks in advance
Michael
I am using code like the following when setting data to a record of a tvirtualtable:
VTTest.Clear; //remove old data
VTTest.Edit;
VTTestI_FIELD1.AsInteger := 100; // dummy kto#
VTTestC_FIELD2.Value := '100'; // dummy kto#
VTTest.Post;
somewhat later I do:
fname := ExtractFileDir(Application.ExeName) + '\Data2.xml';
if FileExists(fname) then VTTest.LoadFromFile(fname);
when I repeat now
VTTest.Clear;
VTTest.Edit;
VTTestI_FIELD1.AsInteger := 100; // dummy kto#
VTTestC_FIELD2.Value := '100'; // dummy kto#
VTTest.Post;
I get an exception in the line after setting editmode maybe because the fielddefs have changed. In fact they are the same (at least similar) as bevor .loadfromfile as the xml which I use in the IDE and while running the programm are nearly the same. They differ solely in data1.xml has no data in it but the data2.xml has. Fielddefs are the same in both xml-files.
My question is. Is it like I think it is
Thanks in advance
Michael