ReadXmlSchema to DataSet adds _Id column

  • Thread starter Joel Sj?berg via DotNetMonster.com
  • 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
 
Joined
Jan 28, 2009
Messages
1
Reaction score
0
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top