Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
how to convert a ADO Recordset to XML and the reverse way Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Convert a ADO Recordset to XML and the reverse way 05-Apr-03
Category
XML
Language
Delphi 5.x
Views
239
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Jonas Bilinkevicius

How to convert a ADO Recordset to XML and the reverse way

Answer:

1   unit ADOXMLUnit;
2   
3   interface
4   
5   uses
6     Classes, ADOInt;
7   
8   function RecordsetToXML(const Recordset: _Recordset): string;
9   function RecordsetFromXML(const XML: string): _Recordset;
10  
11  implementation
12  
13  uses
14    ComObj;
15  
16  function RecordsetToXML(const Recordset: _Recordset): string;
17  var
18    RS: Variant;
19    Stream: TStringStream;
20  begin
21    Result := '';
22    if Recordset = nil then
23      Exit;
24    Stream := TStringStream.Create('');
25    try
26      RS := CreateOleObject('ADODB.Recordset');
27      RS := Recordset;
28      RS.Save(TStreamAdapter.Create(stream) as IUnknown, adPersistXML);
29      Stream.Position := 0;
30      Result := Stream.DataString;
31    finally
32      Stream.Free;
33    end;
34  end;
35  
36  function RecordsetFromXML(const XML: string): _Recordset;
37  var
38    RS: Variant;
39    Stream: TStringStream;
40  begin
41    Result := nil;
42    if XML = '' then
43      Exit;
44    try
45      Stream := TStringStream.Create(XML);
46      Stream.Position := 0;
47      RS := CreateOleObject('ADODB.Recordset');
48      RS.Open(TStreamAdapter.Create(Stream) as IUnknown);
49      Result := IUnknown(RS) as _Recordset;
50    finally
51      Stream.Free;
52    end;
53  end;
54  
55  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC