473,465 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3380

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Markus Seibold | last post by:
Hello NG, sorry for pasting that much code but I just can't figure out how get the <key><keyref> to work in XML Schema. I am using XMLSpy 4.3 for editing my XML. I want to represent a...
2
by: Json | last post by:
Ok, brand new to SQLXML 3.0 and its various issues. Heres what I'm trying to do: 1. I am trying to load xml data into an empty SQL table from my .NET console application. 2. This isn't a huge...
1
by: JSheble | last post by:
I have a dynamically created dataset, created thusly: DataTable dtTime = new DataTable("times"); DataColumn dtColumns = new DataColumn; dtColumns = new DataColumn("id",...
0
by: LunchBox | last post by:
I'm getting null values in a DataSet which is pulling its data from a web service. The nulls are creating 'System.Data.ConstraintException' in the fields that do not allow columns. I've tried...
6
by: Kiran | last post by:
Hi, I am using typed dataset for Employees Table and found a problem, can anyone tell me what's wrong Case 1: Employees Table: ID: int,Not Null,Idendity, Primary col Name:varchar(20),Not...
1
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't...
3
by: Mike | last post by:
Hi, I'm delevloping a webservice that returns typed datasets with visual studio 2005. The problem is, that the typed data set in the client app is not the same as in the webservice. If I change...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
7
by: =?Utf-8?B?TWF4R3J1dmVu?= | last post by:
I have a DLL that implements the Business and Data Layers for a number of different websites. That DLL uses a Strongly Typed DataSet to interface to the Data Source which is SQL Server. There...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.