1

Warning: total rewrite.

Scenario:

I loaded some data from database on a TCustomADODataset descendant. After that, I saved this data on XML temp file (using TCustomADODataset.SaveToFile) to allow getting the XML data as a string and store it on a database table as text blob - it's an exports table.

Another program (different from the one that stored the XML) will take that data, show the elements inside, and allow an user to select which element to import to the main database schema.

Problem:

The problem with the approach above is the need of temporary files to allow TCustomADODataset use the LoadFromFile method.

There's any other way to load that XML data stored as text in the database exports table into a TCustomADODataset that don't need temporary files?

Notes:

  • TClientDataset is not an option in this case.
Fabricio Araujo
  • 3,810
  • 3
  • 28
  • 43
  • Now appear that I was clear. Please, put this comment as answer. Let's see when I comeback to this problem tomorrow and test the torry's code. Thank you. – Fabricio Araujo Oct 18 '11 at 20:57
  • Hard to say, maybe it's because the phrasing is quite complicated. The first time I thought you want the inverse case. Try to simplify it to something like `Is it possible to load data directly from memory to a TClientDataset (without using LoadFromFile) ?` and delete those updates. +1 in the meantime :) – TLama Oct 19 '11 at 17:53

1 Answers1

8

Check this example. It is probably exactly what you are looking for. Using the RecordsetFromXML from that example you can simply assign the recordset to your TCustomADODataSet.Recordset property.

TLama
  • 75,147
  • 17
  • 214
  • 392
  • Seems you has shown the ONLY solution without temp files. Well worthed you bounty.. – Fabricio Araujo Oct 25 '11 at 17:48
  • 1
    Thanks; btw, I think the code in that article is the best approach, because [TCustomADODataSet.LoadFromFile](http://docwiki.embarcadero.com/VCL/en/ADODB.TCustomADODataSet.LoadFromFile) uses the same [Recordset.Open](http://msdn.microsoft.com/en-us/library/windows/desktop/ms675544%28v=vs.85%29.aspx) method as well as [TCustomADODataSet.SaveToFile](http://docwiki.embarcadero.com/VCL/en/ADODB.TCustomADODataSet.SaveToFile) uses the [Recordset.Save](http://msdn.microsoft.com/en-us/library/windows/desktop/ms681501%28v=vs.85%29.aspx) with the only difference they are using streams instead of files. – TLama Oct 25 '11 at 18:01