Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One dataset. Two XML files
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
One dataset. Two XML files
Divers
Thread ID:
01095548
Message ID:
01095548
Vues:
52
Here is what I want to do:
I have created a typed dataset that has two tables, lets call the tables Table1 and Table2. I receive two XML files, the first XML file (XmlFile1) contains the data for Table1 and the 2nd XML file (XmlFile2) contains data for Table2.

Now I want to read the data from XmlFile1 and XmlFile2 into my dataset using the ReadXml() method of my dataset. Something like this:
myTypedDataSet ds = new myTypedDataSet();
ds.ReadXml(@"C:\somewhere\XmlFile1.xml");
ds.ReadXml(@"C:\somewhere\XmlFile2.xml");
Now this does not work as I would expect (obviously otherwise I would have posted this message<s>). I want the first ReadXml() to fill ds.Table1 and the 2nd ReadXml() to fill ds.Table2, but neither ds.Table1 nor ds.Table2 has any data in it.

I wouldn't be surprised if it has something with XmlReadMode (can be passed to ReadXml()), but I tried to use IgnoreSchema without any luck and I also tried Auto.

I am doing this as an effort to make the code better. currently I have two typed datasets ds1 and ds2 which contains Table1 and Table2 respectively. My current code that looks a little like this works great:
myTypedDataSet1 ds1 = new myTypedDataSet1();
ds1.ReadXml(@"C:\somewhere\XmlFile1.xml", XmlReadMode.IgnoreSchema);
myTypedDataSet2 ds2 = new myTypedDataSet2();
ds2.ReadXml(@"C:\somewhere\XmlFile2.xml", XmlReadMode.IgnoreSchema);
I could swear I have done something like this before (but that was in 1.1) and I can't grasp why it doesn't work now.

Any thoughts?

Einar
Semper ubi sub ubi.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform