Recent

Author Topic: TSQLQuery SaveToFile using dfXMLUTF8 & dfXML options give me an empty file  (Read 4465 times)

JD

  • Hero Member
  • *****
  • Posts: 1848
Hi there everyone,

Is there a problem with TSQLQuery's SaveToFile method? When I save a dataset to disk using
SaveToFile('test.xml'), I get a file with data inside it. But when I change it to SaveToFile('test.xml', dfXMLUTF8) or SaveToFile('test.xml', dfXML), I get an empty file.

HAs anyone had a similar experience on this forum?

Thanks,

JD

Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

LacaK

  • Hero Member
  • *****
  • Posts: 691
SaveToFile without 2nd parameter uses default dfBinary format (so it is not XML)
You must put in your uses clause: uses xmldatapacketreader then this unit will register datapacket reader/writer for dfXML
(for dfXMLUTF8 there is no supplied unit so this format is not supported ... You should get exception)

JD

  • Hero Member
  • *****
  • Posts: 1848
SaveToFile without 2nd parameter uses default dfBinary format (so it is not XML)
You must put in your uses clause: uses xmldatapacketreader then this unit will register datapacket reader/writer for dfXML
(for dfXMLUTF8 there is no supplied unit so this format is not supported ... You should get exception)

Thanks LacaK. It worked just like you suggested.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

 

TinyPortal © 2005-2018