Link to home
Start Free TrialLog in
Avatar of Mr_Ezi
Mr_Ezi

asked on

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,
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Try retrieving the query results as XML from the SQL Server

http://articles.sitepoint.com/article/data-as-xml-sql-server
Avatar of Mr_Ezi
Mr_Ezi

ASKER

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...
Have you tried DataSet.WriteXML(filename, , XmlWriteMode.DiffGram) ???

Dabas
Avatar of Mr_Ezi

ASKER

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

Dabas
Avatar of Mr_Ezi

ASKER

Oh Let's try it, Thanks
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mr_Ezi

ASKER

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
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 
Avatar of Mr_Ezi

ASKER

No I'm sure its not a hard drive problem.

I have it on a few different computers
Avatar of Mr_Ezi

ASKER

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)

Avatar of Mr_Ezi

ASKER

Thanks, I had to figure out the stuff my self, but your tip to use a stream helped a lot...