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