468,530 Members | 1,568 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,530 developers. It's quick & easy.

keyref relationship in Typed Dataset causes System.Data.ConstraintException

Hi

I have two tables in my database. PRODUCT and PRODUCT_GROUP. PRODUCT has a foreign key to PRODUCT_GROUP. I generated a typed dataset using VS.net and added a relationship between the two tables. When I call my get WebMethod for the PRODUCT table I get the System.Data.ConstraintException exception. The get WebMethod for PRODUCT_GROUP works fine. When I remove the relationship the get WebMethod for PRODUCT works fine too. Both tables only have one row of data in them and the database is already enforcing the relationship. Also if I delete my one row of info in PRODUCT, the webservice works fine. What am I doing wrong. Please help

Here is the .xsd

<?xml version="1.0" standalone="yes" ?><xs:schema id="ProductTestDataSet" targetNamespace="http://www.tempuri.org/ProductTestDataSet.xsd
xmlns:mstns="http://www.tempuri.org/ProductTestDataSet.xsd" xmlns="http://www.tempuri.org/ProductTestDataSet.xsd
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata
attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="ProductTestDataSet" msdata:IsDataSet="true"><xs:complexType><xs:choice maxOccurs="unbounded"><xs:element name="PRODUCT_GROUP"><xs:complexType><xs:sequence> <xs:element name="ID" msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" /><xs:element name="NAME" type="xs:string" minOccurs="0" /></xs:sequence></xs:complexType></xs:element><xs:element name="PRODUCT"><xs:complexType><xs:sequence><xs:el ement name="ID" msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" /><xs:element name="NAME" type="xs:string" minOccurs="0" /><xs:element name="PRODUCT_GROUP_ID" type="xs:int" minOccurs="0" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><xs:unique name="Constraint1" msdata:PrimaryKey="true"><xs:selector xpath=".//mstns:PRODUCT_GROUP" /><xs:field xpath="mstns:ID" /></xs:unique><xs:unique name="ProductSelectCommand_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true"><xs:selector xpath=".//mstns:PRODUCT" /><xs:field xpath="mstns:ID" /></xs:unique><xs:keyref name="PRODUCT_GROUPPRODUCT" refer="mstns:Constraint1" msdata:AcceptRejectRule="None
msdata:DeleteRule="None" msdata:UpdateRule="None"><xs:selector xpath=".//mstns:PRODUCT" /><xs:field xpath="mstns:PRODUCT_GROUP_ID" /></xs:keyref></xs:element></xs:schema

Thanks

Nim

ps. Here is the full error

System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints
at System.Data.DataSet.FailedEnableConstraints(
at System.Data.DataSet.EnableConstraints(
at System.Data.DataSet.set_EnforceConstraints(Boolean value
at System.Data.DataTable.EndLoadData(
at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDataReader dataReader
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable
at SimpleTestingProduct.Service1.getProduct() in c:\inetpub\wwwroot\simpletestingproduct\service1.a smx.cs:line 25

Nov 16 '05 #1
0 3131

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Markus Seibold | last post: by
1 post views Thread by JSheble | last post: by
reply views Thread by LunchBox | last post: by
6 posts views Thread by Kiran | last post: by
3 posts views Thread by Mike | last post: by
21 posts views Thread by Peter Bradley | last post: by
7 posts views Thread by =?Utf-8?B?TWF4R3J1dmVu?= | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.