S
Sunny
Hi,
I'm using VS.net 2003 and C#.
I created (using buildin designer) a dataset with 2 tables.
TableOne has 2 fields: sName and sTable (both string) and a primary key
TestKey, set on sName.
TableData has 2 fields: sName and sData (both strings).
I have made a relation, based on sName, where TableOne is parent
element, and TableData is child. All other settings are default.
The designer generated the class and .xsd file.
In my code I have:
Dataset1 myTable = new Dataset1();
myTable.ReadXmlSchema(@"Dataset1.xsd");
and ReadXmlSchema throws an exception:
An unhandled exception of type 'System.Data.DataException' occurred in
system.data.dll
Additional information: Invalid 'Key' node inside constraint named:
TableOneTableData.
What I'm doing wrong?
I need the data set to store some user data and to save it to disk as
XML for future retrieval.
Thanks
Sunny
P.S. Here is the .xsd file (with line wraps):
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Dataset1"
targetNamespace="http://tempuri.org/Dataset1.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://tempuri.org/Dataset1.xsd"
xmlns:mstns="http://tempuri.org/Dataset1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Dataset1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="TableOne">
<xs:complexType>
<xs:sequence>
<xs:element
name="sName" type="xs:string" minOccurs="0" />
<xs:element
name="sValue" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TableData">
<xs:complexType>
<xs:sequence>
<xs:element
name="sName" type="xs:string" minOccurs="0" />
<xs:element
name="sData" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="TestKey" msdatarimaryKey="true">
<xs:selector xpath=".//mstns:TableOne" />
<xs:field xpath="mstns:sName" />
</xs:key>
<xs:keyref name="TableOneTableData" refer="TestKey">
<xs:selector xpath=".//mstns:TableData" />
<xs:field xpath="mstns:sName" />
</xs:keyref>
</xs:element>
</xs:schema>
I'm using VS.net 2003 and C#.
I created (using buildin designer) a dataset with 2 tables.
TableOne has 2 fields: sName and sTable (both string) and a primary key
TestKey, set on sName.
TableData has 2 fields: sName and sData (both strings).
I have made a relation, based on sName, where TableOne is parent
element, and TableData is child. All other settings are default.
The designer generated the class and .xsd file.
In my code I have:
Dataset1 myTable = new Dataset1();
myTable.ReadXmlSchema(@"Dataset1.xsd");
and ReadXmlSchema throws an exception:
An unhandled exception of type 'System.Data.DataException' occurred in
system.data.dll
Additional information: Invalid 'Key' node inside constraint named:
TableOneTableData.
What I'm doing wrong?
I need the data set to store some user data and to save it to disk as
XML for future retrieval.
Thanks
Sunny
P.S. Here is the .xsd file (with line wraps):
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Dataset1"
targetNamespace="http://tempuri.org/Dataset1.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://tempuri.org/Dataset1.xsd"
xmlns:mstns="http://tempuri.org/Dataset1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Dataset1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="TableOne">
<xs:complexType>
<xs:sequence>
<xs:element
name="sName" type="xs:string" minOccurs="0" />
<xs:element
name="sValue" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TableData">
<xs:complexType>
<xs:sequence>
<xs:element
name="sName" type="xs:string" minOccurs="0" />
<xs:element
name="sData" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="TestKey" msdatarimaryKey="true">
<xs:selector xpath=".//mstns:TableOne" />
<xs:field xpath="mstns:sName" />
</xs:key>
<xs:keyref name="TableOneTableData" refer="TestKey">
<xs:selector xpath=".//mstns:TableData" />
<xs:field xpath="mstns:sName" />
</xs:keyref>
</xs:element>
</xs:schema>