Solved

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

Posted on 2008-10-22
2
368 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now