Solved

write text from database to xml file

Posted on 2008-06-20
3
247 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:Jason Evans
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

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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 …
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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