Write Datatable data to XML string for database storage (.NET 1.1)

How can I write a datatable's content as an XML String for storing in a database? The only examples I found were for writing to an XML file.  
LVL 1
ZekeLAAsked:
Who is Participating?
 
ZekeLAConnect With a Mentor Author Commented:
I didn't want to write to a file. Here is the solution I found from another site:

StringWriter stringWriter = new StringWriter();
dt.WriteXml(stringWriter, XmlWriteMode.WriteSchema);
string s = stringWriter.ToString();
0
 
Wayne Taylor (webtubbs)Commented:
Hi ZekeLA,

You'll need to write the XML to file, then read that file using a TextReader or something....

    Dim tmp As String = My.Computer.FileSystem.GetTempFileName
    YourDataSet.WriteXml(tmp)
    Dim xmlString As String = IO.File.ReadAllText(tmp)

Regards,

Wayne
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.