Solved

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

Posted on 2008-10-22
2
373 Views
Last Modified: 2013-11-07
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.  
0
Comment
Question by:ZekeLA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22781491
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
 
LVL 1

Accepted Solution

by:
ZekeLA earned 0 total points
ID: 22909484
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

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question