I'm experiencing a little problem here with my code:

DataSet _ds = new DataSet();

//convert xml to dataset
_ds.ReadXml(textBox1.Text);

try
{
//Create a relation between the Authors and the Titles tables.
       _ds.Relations.Add("Level", _ds.Tables["HEADER"].Columns["IDMAT"], _ds.Tables["ITEM"].Columns["IDNRK"]);
}
catch(DataException dt)
{
    util.logThis("ERROR while Adding Dataset Relations between tables / UI / ProcessClick event : " + dt.ToString(), "error");  
}

Exception System.ArgumentException was thrown in debuggee:
This constraint cannot be enabled as not all values have corresponding parent values.

By default there is no constraint set...so i was wandering what was going wrong?

Has IDMAT duplicated values?!

Nope...here a sample of the file:

<?xml version="1.0"?>

<BOM>
  <HEADER>
   <IDMAT>1111</IDMAT>
  </HEADER>
  <ITEM>
   <IDNRK>1234</IDNRK>
   ...
  </ITEM>
  <ITEM>
   <IDNRK>1123</IDNRK>
   ...
  </ITEM>
  <ITEM>
   <IDNRK>1132</IDNRK>
   ...
  </ITEM>
</BOM>
<BOM>
  <HEADER>
   <IDMAT>1123</IDMAT>
  </HEADER>
  <ITEM>
   <IDNRK>1234</IDNRK>
   ...
  </ITEM>
  <ITEM>
   <IDNRK>1144</IDNRK>
   ...
  </ITEM>
  <ITEM>
   <IDNRK>1192</IDNRK>
   ...
  </ITEM>
</BOM>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.