Exception Invalid 'Key' node inside constraint

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(@"D: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" msdata:primaryKey="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>
 
Y

Yan-Hong Huang[MSFT]

Hello Sunny,

Thanks for the post.

I have replied it in vsnet.ide group. Please check it when you have free
time. I will follow up the issue there.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: Sunny <[email protected]>
!Subject: Exception Invalid 'Key' node inside constraint
!Date: Wed, 10 Sep 2003 16:31:23 -0500
!Message-ID: <[email protected]>
!Organization: Iceberg Wireless LLC
!MIME-Version: 1.0
!Content-Type: text/plain; charset="iso-8859-15"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: MicroPlanet Gravity v2.60
!Newsgroups:
microsoft.public.dotnet.languages.csharp,microsoft.public.dotnet.xml,microso
ft.public.vsnet.ide
!NNTP-Posting-Host: c-66-41-159-114.mn.client2.attbi.com 66.41.159.114
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.xml:15728
microsoft.public.vsnet.ide:8095
microsoft.public.dotnet.languages.csharp:183890
!X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
!
!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(@"D: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" msdata:primaryKey="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>
!
 
C

Christian Boult

You don't need to read the schema if your using the dataset generated by the
MS tool.
It creates it all by itself, that's the main idea behind typed datasets.

Chris.
 
S

Sunny

You don't need to read the schema if your using the dataset generated by the
MS tool.
It creates it all by itself, that's the main idea behind typed datasets.

Chris.


Thanks Cris and Yan-Hong

Sunny
 
Y

Yan-Hong Huang[MSFT]

Hi Sunny,

You are welcome.

Thanks for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: Sunny <[email protected]>
!Subject: Re: Exception Invalid 'Key' node inside constraint
!Date: Thu, 11 Sep 2003 21:00:35 -0500
!Message-ID: <[email protected]>
!References: <[email protected]>
<#[email protected]>
!Organization: Iceberg Wireless LLC
!MIME-Version: 1.0
!Content-Type: text/plain; charset="iso-8859-15"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: MicroPlanet Gravity v2.60
!Newsgroups:
microsoft.public.dotnet.languages.csharp,microsoft.public.dotnet.xml,microso
ft.public.vsnet.ide
!NNTP-Posting-Host: c-66-41-159-114.mn.client2.attbi.com 66.41.159.114
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.xml:15787
microsoft.public.vsnet.ide:8131
microsoft.public.dotnet.languages.csharp:184263
!X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
!
!In article <#[email protected]>, (e-mail address removed)
!says...
!> You don't need to read the schema if your using the dataset generated by
the
!> MS tool.
!> It creates it all by itself, that's the main idea behind typed datasets.
!>
!> Chris.
!>
!
!
!Thanks Cris and Yan-Hong
!
!Sunny
!
 

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