Save Clientdataset data to an XML file

Asked

Viewed 6,289 times

2

I made a simple registration system without involving database, I need to know how I write files of the Clientdataset register in an XML file and when I go to query they appear in my grid!

  • So I was able to generate the XML file- just by clicking on the Clientdataset with the right mouse button and on the 'Save to Mybase XML table' option now I need to set to save in this file.

1 answer

4


To save the TClientDataSet in an xml file:

ClientDataSet1.SaveToFile('c:\teste.xml', dfXML); //Como bem lembrado pelo @Caputo

To carry the TClientDataSet of an xml file:

ClientDataSet1.LoadFromFile('c:\teste.xml');

File created by the Savetofile command:

inserir a descrição da imagem aqui

  • 3

    Only one addendum. In the save to file method, I recommend using the second parameter as dfBinary or dfXML which refers to the format of the data in the file. The default if not informed is dfBinary

  • @Caputo +1 for the memory, strange here to have saved straight in the example.

  • It is that the parameter has a default for dfBinary. Your example is right, besides being the most used way

Browser other questions tagged

You are not signed in. Login or sign up in order to post.