DataSet.WriteXml(FileName.xml) aborts, and no exception is thrown

Hi,

I am reading data from several database tables into a dataset and writing it to xml file using DataSet.WriteXML() method - overall the file size could be 7-10mb.  For the most part this works fine, however, on few occasions it has been noticed that only partial data is written to xml, or letter's are missing from tags (like: <TransID>1001</T ansID>).

No exception is thrown - the error is realized only when next time the file is read.  

I would also like to know whether,

1) DataSet.WriteXML() has limitation in terms of the file size? and, can we somehow verify whether the data written by WriteXML() is complete?

2) Is there any other safer way to write the data from the database to xml file?

Thanks in advance,
Mr_EziAsked:
Who is Participating?
 
grayeCommented:
Hummm.... is this a multi-threaded application?
Here is something to try.... instead of using the file name as the argument to WriteXML, try using a FileStream object.   That way you'd have complete control over the opening, writing, flushing, and closing of the stream.  In theory, that's probably the same steps that are supposed to occur when using just a file name... but what the heck, it's worth a try.
On the other hand, I'd seriously consider runing the File System Checker on that drive to see if you have a corrupted file system.
0
 
CodeCruiserCommented:
Try retrieving the query results as XML from the SQL Server

http://articles.sitepoint.com/article/data-as-xml-sql-server
0
 
Mr_EziAuthor Commented:
Thanks for this tip, but it doesn't solve the problem, because I need to write the changes from the application's dataset back into the xml file.

If there is a way to write back just the data I changed that will help a lot!

But I don't think there is one...
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
DabasCommented:
Have you tried DataSet.WriteXML(filename, , XmlWriteMode.DiffGram) ???

Dabas
0
 
Mr_EziAuthor Commented:
No I didn't, what will that help?
0
 
DabasCommented:
oops. Remove extra comma
0
 
DabasCommented:
It is a way to find out only the data that has changed.
You did say that will help a lot

Dabas
0
 
Mr_EziAuthor Commented:
Oh Let's try it, Thanks
0
 
Mr_EziAuthor Commented:
No it's not a multi-threaded application.

Thanks for your tip.

But I want to try first the XmlWriteMode.DiffGram because the problem ONLY happens when I write big files, so if  I'll be able to write just the changes then I'm fine.

But I'm not sure how this works
0
 
grayeCommented:
Did you do a Check Disk operation on your disk to see if you had any issues?
http://www.ehow.com/how_4967757_run-chkdsk-utility-vista.html 
0
 
Mr_EziAuthor Commented:
No I'm sure its not a hard drive problem.

I have it on a few different computers
0
 
Mr_EziAuthor Commented:
Ok I found a way to write just the new data, the problem is that it writes the <MainDataSet>  and </MainDataSet> tags again, How can I get rid of it?

Dim ChangedDS As DataSet = ds.GetChanges()
fs = New FileStream(SDCardPath + "\" + CustomerID + ".xml", IO.FileMode.Append)
ChangedDS.WriteXml(fs)

0
 
Mr_EziAuthor Commented:
Thanks, I had to figure out the stuff my self, but your tip to use a stream helped a lot...
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.