Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One dataset. Two XML files
Message
De
11/02/2006 20:45:42
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01095548
Message ID:
01095680
Vues:
10
>It is working right if I use InferSchema, but it does not work if I use IgnoreSchema.<

Well then, I guess that answers your question about which one to use! <g> Actually, I've never used IgnoreSchema, I've always used InferSchema.

~~Bonnie



>I have one typed dataset with 5 tables in it. All the tables have a foreign key constraint "linking" all the tables together. I receive 2 xml files. One xml file contains the data for the first 4 tables in the dataset and the last xml file contains the data for the last table in the dataset.
>Usually when I read one xml file into a typed dataset I use IgnoreSchema, but that XmlReadMode did not work when the xml file does not contain all the tables that are defined in the dataset.
>
>Einar
>
>
>>No, my XML did not have any schema. What exactly is not working right?
>>
>>~~Bonnie
>>
>>
>>
>>>I forgot to mention that my XML files does not have the schema in them.
>>>I had 2nd thoughts about InferSchema because it could add tables or columns based on that was in the XML files. The more I thought about this it doesn't really matter. I am using a typed dataset with uniqe constraints on every field and there are foreignkey relations between all tables, so if my supplier of XML files want to add extra tables or fields (as long as he also sends me what I want) that is OK.
>>>
>>>Do you include the schema in the XML file whem you send it somewhere? (or do you recaive XML files with schema?)
>>>
>>>Einar
>>>
>>>>I've tried both XmlReadMode.InferSchema and XmlReadMode.ReadSchema. They work in slightly different manners, but they still should do what you want. InferSchema will add columns if they don't already exist in your DataSet, ReadSchema won't add the extra columns. Auto should work the same as ReadSchema, but if it wasn't working with Auto I bet you didn't have the tables names in the XML corresponding to the table names in your DataSet.
>>>>
>>>>Why did you say you're having second thoughts about InferSchema?
>>>>
>>>>~~Bonnie
>>>>
>>>>
>>>>
>>>>>Well it appears that XmlReadMode.InferSchema does what I want the ReadCml() method to do, but after reading about XmlReadMode.InferSchema I am having 2nd thoughts.
>>>>>
>>>>>Has anoyone else in here done something similar to what I want to do?
>>>>>
>>>>>Einar
>>>>>
>>>>>>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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform