Solved

write text from database to xml file

Posted on 2008-06-20
3
246 Views
Last Modified: 2012-05-05
Ive got the xml stored in a database (tags and everything). I basically want to just read the cell (stored in one column of one row) and write it out to an file of type .xml.
I did this with streamwriter and it worked fine except that some of the text is getting cut off thus not making the xml file unusable. It seems to be a limit to the amount of data that can be streamed. Is there some way to achieve this?
Is it as easy as writing it to a text file then changing the extension of the text file to .xml?
0
Comment
Question by:slrine2000
[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
3 Comments
 
LVL 10

Expert Comment

by:MrClyfar
ID: 21833994
Hi slrine2000.

Just to check, you said that the data was being cut off - are you sure that all of the xml data is stored in the database column (cell) ? If all the xml data is fine, then could you post the source code you are using to read the xml data and save it to a file?

Cheers.
Jas.
0
 

Author Comment

by:slrine2000
ID: 21834232
'SQL UP HERE
Dim dr As SqlDataReader
        Dim SQLcommand As New SqlCommand(SQL, Conn)
        Conn.Open()
        dr = SQLcommand.ExecuteReader
        Dim objStreamWriter As StreamWriter
        While dr.Read() = True
            'Open the file.
            objStreamWriter = New StreamWriter("C:\Temp\Test.xml")
            txtDisplay.Text = dr.Item(0)
            'Close the file.
            objStreamWriter.Write(txtDisplay.Text)
            objStreamWriter.Flush()
            objStreamWriter.Close()
        End While
        Conn.Close()
I put it to a text box to see if I was returning everything via the datareader because I wasnt sure if there was a limit on the datareader or the streamwriter. It seems that there is a limit on the stream writer.
0
 
LVL 7

Accepted Solution

by:
Dauhee earned 250 total points
ID: 21837441
how about a 1 liner :)
My.Computer.FileSystem.WriteAllText('C:\file.xml', 'xml stuff here', True, System.Text.Encoding.ASCII)

Dont forget to use System.Text.Encoding.ASCII though as you will get some lovely hidden binary chars in it otherwise and can cause all sorts of fun . . . . thats 5 hours of my life I will never get back . . .
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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