Save and load xml

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

Save and load xml

Post by oz8hp » Mon 13 Sep 2010 06:09

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)

AndreyZ

Post by AndreyZ » Mon 13 Sep 2010 08:01

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.

oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

Post by oz8hp » Mon 13 Sep 2010 09:35

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.

AndreyZ

Post by AndreyZ » Mon 13 Sep 2010 12:17

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.

oz8hp
Posts: 151
Joined: Mon 18 Feb 2008 13:28
Location: Denmark
Contact:

Post by oz8hp » Tue 14 Sep 2010 05:03

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.

AndreyZ

Post by AndreyZ » Tue 14 Sep 2010 09:29

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;"

Post Reply