Ramon Smits

Tell me your secrets and i'll tell you mine

Recent Posts

Tags

Community

Email Notifications

Patterns & Practices / Guidelines

EntLib

Nant

Blogs that I monitor

Archives

Import/export by using DataSet WriteXml and ReadXml

I just tried to create a simpel import/export feature in one of our applications based on XML. My first thought was: Create a typed dataset and for export just serialize it to XML with the WriteXml method and for import deserialize it by using ReadXml.


Well the write part created exactly the file that I wanted but the ReadXml did not work as expected. No exceptions occured but no data was read so I could not add the data to the database. I remembered that I probably had to do with a schema option. Either at the write or the read. I wanted the write to behave like it was doing now. So browsing MSDN gave me the answer that I had to use the XmlReadMode.InferSchema parameter to the ReadXml method. That uses typed dataset information to check for data consistency.


So now my simple import/export is working again and it appears that my (typed) dataset knowledge was a bit rusted by not using it for quite a while.

Comments

Andy said:

I've been trying to do this but it it just refuses to read the data back into my dataset!

# September 7, 2009 3:25 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Please add 2 and 6 and type the answer here: