Click to See Complete Forum and Search --> : Question about associating primary key from XML schema


rpv_us
June 11th, 2003, 01:03 PM
Hi,

I have created an XML schema for XML file. Then defined the primary key using Visual Studio.net ( Add Key -> Set one of the XML element as primary key).

To extract data based on the primary key value, I created a DataSet from the XML file by using
DataSet.ReadXMLSchema(*.xsd) followed by
DataSet.ReadXML(*.xml)

The DataSet is populated with the XML file contents, but it fails to identify the primary key and the Rows.Find(primary_key_value) / Rows.Contains (primary_key_value) gives the MissingPrimaryKeyException.

I did a quick watch on the DataSet and the Primary Key Value is null, so I think the primary key value is not picked up from the XML schema.

But the XML schema file contains ( generated by VS>NET):
<xs:key name="EmployeeKey1" msdata:PrimaryKey="true">
<xs:selector xpath="." />
<xs:field xpath="mstns:userID" />
</xs:key>

Could someone please point out why the operation might be failing ? I am rather stuck at this point.

Appreciate your help.