Read\ Write " XML" file to foxpro memo field with ClientDataSet.

I'm need to store   ClientDataSet  " XML"  file to foxpro memo  field , is any way to implement this?
It seems to me, that  I have to use SAVETOSTREAM()  \ LOADFROMSTREAM() function .
Is it right? Thanks.
astronmAsked:
Who is Participating?
 
JohnjcesConnect With a Mentor Commented:
Is your XML a physical file which is created and then needs to be stored in your memo field? Like "c:\MyFoxProXMLFiles\MyFile.xml"?

And then recreated when needed?

Or is this directoy out of the ClientDataSet such as ClientdataSet1.SavetoStream....

And how is your FoxPro table accessed? ADO? Delphi version? 2006?

But, yes, you probably will have to use streams.

Here is an example using ADO.... (uses a blob filed not a memo and a treeview. Substitute your ClientDataSet for TreeView1)

procedure TreeViewToTable;
var
 vlstream : TMemoryStream;
begin
 Screen.Cursor := crHourGlass;
 vlStream := TMemoryStream.Create();
 TreeView1.SaveToStream(vlStream);
 vlStream.Seek(0, soFromBeginning);
(ADOQuery1.FieldByName('Details') as TBlobField).LoadFromStream(vlStream);
 vlStream.Free;
 Screen.Cursor := crDefault;
end;

procedure TFCDLib.TableToTreeView(DoIt : Boolean);
var
 vlStream: TMemoryStream;
begin
 Screen.Cursor := crHourGlass;
 TreeView1.Items.Clear;
 vlStream := TMemoryStream.Create();
 (ADOQuery1.FieldByName('Details') as TBlobField).SaveToStream(vlStream);
 vlStream.Seek(0, soFromBeginning);
 TreeView1.LoadFromStream(vlStream);
 vlStream.Free;
end;

John
0
 
CarlWarnerCommented:
See the following functions:

XMLTOCURSOR( ) Function
http://msdn2.microsoft.com/en-us/library/t2s4axst(VS.80).aspx

CURSORTOXML( ) Function
http://msdn2.microsoft.com/en-us/library/3badwbtz(VS.80).aspx

Converting Between XML and Visual FoxPro Data
http://msdn2.microsoft.com/en-us/library/cbbwtcbh(VS.80).aspx
0
 
astronmAuthor Commented:
Thank you John,
 that was I  think I was looking for.
It is directly out of the ClientDataSet .

"Use TBlobStream to access or modify the value of a BLOB field object.
There are three predefined field types that will work with BLOB streams (TBlobField, TGraphicField, and TMemoField)."(ADS  help file)

 I'm using TAdsBlobStream ( advantage data base) which   is a descendant from TStream  and  very similar to a TBlobStream implementation.


0
 
JohnjcesCommented:
Modify it up for your database and access and let us know if it worked OK for you!

John
0
 
JohnjcesCommented:
Any luck?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.