Page 1 of 1

Save and load xml

Posted: Mon 13 Sep 2010 06:09
by oz8hp
Does a small example exist that shows how to save a table to an xml file and later load data from an xml file to the same table?

(I need this to exchange data between 2 locations)

Posted: Mon 13 Sep 2010 08:01
by AndreyZ
Hello,

To save a table to an XML file you have to use the SaveToXML procedure of the TUniTable component like this:

Code: Select all

UniTable.SaveToXML('your XML filename');
After that you can load this XML file into the TVirtualTable component like this:

Code: Select all

VirtualTable.LoadFromFile('your XML filename');
Also you can use TUniDump to store data from tables as a script and to restore data from a received script. Please, take a look at the UniDAC demo.

Posted: Mon 13 Sep 2010 09:35
by oz8hp
I may be stupid but I can't figure out how to load data to a 'real' table
As I understand it a VitualTable exists only in memory.

Posted: Mon 13 Sep 2010 12:17
by AndreyZ
You have to use the TCRBatchMove component to transfer data between all types of TDataSet descendants.
Here is an example:

Code: Select all

CRBatchMove.Destination := UniTable;
CRBatchMove.Source := VirtualTable;
CRBatchMove.Execute;
Note that this component is placed on the Data Access page of the Component palette, not on the UniDAC page.

Posted: Tue 14 Sep 2010 05:03
by oz8hp
Thanks - I got a small sample up and running.

But now I found that the normal TQuery doesn't have the SaveToXML function that TUniQuery has. And TUniQuery doesn't give access to my old Paradox tables.
So I am back to the start once again :o

But thanks once again any way.

Posted: Tue 14 Sep 2010 09:29
by AndreyZ
The TCRBatchMove component is transfering data between all types of the TDataSet descendants. So, you can use it for transfer data from the TQuery component to the TUniTable or TUniQuery components and backwards.

If you want to use the TUniQuery component to get access to your Paradox tables, then you can use an ODBC driver.
For that you have to do the following steps:
- set the TUniConnection.ProviderName property to ODBC;
- set the TUniConnection.SpecifyOptions.DSNType option to ntConnectionString;
- set the TUniConnection.LoginPromt property to False;
- set the TUniConnection.Server property to your ConnectionString.
Here an example of ConnectionString:

Code: Select all

Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="CollatingSequence=ASCII;DefaultDir=E:\projects;Driver={Driver do Microsoft Paradox (*.db )};DriverId=538;FIL=Paradox 5.X;FILEDSN=E:\projects\pdx.db.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;ParadoxNetPath=D:\WINDOWS\system32;ParadoxNetStyle=4.x;ParadoxUserName=admin;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"