ReadXmlSchema to DataSet adds _Id column

  • Thread starter Thread starter Joel Sj?berg via DotNetMonster.com
  • Start date Start date
J

Joel Sj?berg via DotNetMonster.com

Hi,
I'm trying to load a schema ReadXmlSchema with defined key and relation
into a dataset but the result is that VS adds the _Id column anyway what am
I doing wrong?

Regards, Joel
 
i just spent about 8 hours working this out and thought I would post to help any others who also found this post using via google.

i have an xml schema containing nested elements with a keyref field as so:

Code:
  <orders>
   <order orderid="1234">
 	  <item orderid="1234">
 	  <item orderid="1234">
 	  <item orderid="1234">
   <order>
 	....
   <order>
 </orders>

Code:
 		<xs:unique name="pkOrder">
 			<xs:selector xpath=".//order" />
 			<xs:field xpath="@orderid" />
 		</xs:unique>
 		<xs:keyref name="order_item" refer="pkOrder">
 			<xs:selector xpath=".//item" />
 			<xs:field xpath="@orderid" />
 		</xs:keyref>

then ran the c#:

Code:
  DataSet ds = new DataSet();
 string schema_file_path = "c:\myschema.xsd";

when I did:

Code:
 ds.ReadXmlSchema(schema_file_path)

visual always added two column Order_ID and Item_ID.

I finally figured it out - you have to name your Dataset the same as the ROOT element of your Xml schema.

so i did

DataSet ds = new DataSet("orders");

and it worked!
 
Back
Top