473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

I have an xsd dataset. I created a simple query called GetDataByUserId. I
can preview the data fine!

I created a very simple BLL function that calls it and returns a datatable.

When I run the code I get....

=======================

Server Error in '/MyCompanyMyProject' Application.
Failed to enable constraints. One or more rows contain values violating
non-null, unique, or foreign-key constraints.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.ConstraintException: Failed to enable
constraints. One or more rows contain values violating non-null, unique, or
foreign-key constraints.

Source Error:

Line 2366: End If
Line 2367: Dim dataTable As dsUsers.myoptionsDataTable = New
dsUsers.myoptionsDataTable
Line 2368: Me.Adapter.Fill(dataTable) <==== LINE IS IN RED!
Line 2369: Return dataTable
Line 2370: End Function

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\MyCompanyMyProject\7eeeedcd\743a3129\App_Cod e.zobkgcsa.15.vb Line:
2368

=======================

Any idea why?

I verified all the data, that no pk/fk are violated, etc... Even when I
turn 'enforce constraints' off in the xsd dataset properties it still fails.
Oct 31 '08 #1
4 21941

You have to ~~anally~~ go over the column names...of your ResultSet.
And compare to the strong dataset.

~anally~

Every columnName....

My guess is that you're either not returning a certain column or ... you
have a mismatched name.

Select LastName from dbo.Emp

and you ds has "LName" in the column name or something like that.

Check datatypes as well!

"Bobby Edward" <bo***@nobody.comwrote in message
news:eV**************@TK2MSFTNGP02.phx.gbl...
>I have an xsd dataset. I created a simple query called GetDataByUserId. I
can preview the data fine!

I created a very simple BLL function that calls it and returns a
datatable.

When I run the code I get....

=======================

Server Error in '/MyCompanyMyProject' Application.
Failed to enable constraints. One or more rows contain values violating
non-null, unique, or foreign-key constraints.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.ConstraintException: Failed to enable
constraints. One or more rows contain values violating non-null, unique,
or foreign-key constraints.

Source Error:

Line 2366: End If
Line 2367: Dim dataTable As dsUsers.myoptionsDataTable = New
dsUsers.myoptionsDataTable
Line 2368: Me.Adapter.Fill(dataTable) <==== LINE IS IN RED!
Line 2369: Return dataTable
Line 2370: End Function

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET Files\MyCompanyMyProject\7eeeedcd\743a3129\App_Cod e.zobkgcsa.15.vb
Line: 2368

=======================

Any idea why?

I verified all the data, that no pk/fk are violated, etc... Even when I
turn 'enforce constraints' off in the xsd dataset properties it still
fails.


Oct 31 '08 #2
Thanks.

It's a simple SELECT of all the fields in the table WHERE xxxx = input
param. When I preview it (in dataset designer) it's fine, even passing it
the same variable.

When I run it thru code it fails.

Any ideas?

"sloan" <sl***@ipass.netwrote in message
news:ev**************@TK2MSFTNGP04.phx.gbl...
>
You have to ~~anally~~ go over the column names...of your ResultSet.
And compare to the strong dataset.

~anally~

Every columnName....

My guess is that you're either not returning a certain column or ... you
have a mismatched name.

Select LastName from dbo.Emp

and you ds has "LName" in the column name or something like that.

Check datatypes as well!

"Bobby Edward" <bo***@nobody.comwrote in message
news:eV**************@TK2MSFTNGP02.phx.gbl...
>>I have an xsd dataset. I created a simple query called GetDataByUserId.
I can preview the data fine!

I created a very simple BLL function that calls it and returns a
datatable.

When I run the code I get....

=======================

Server Error in '/MyCompanyMyProject' Application.
Failed to enable constraints. One or more rows contain values violating
non-null, unique, or foreign-key constraints.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.ConstraintException: Failed to enable
constraints. One or more rows contain values violating non-null, unique,
or foreign-key constraints.

Source Error:

Line 2366: End If
Line 2367: Dim dataTable As dsUsers.myoptionsDataTable = New
dsUsers.myoptionsDataTable
Line 2368: Me.Adapter.Fill(dataTable) <==== LINE IS IN RED!
Line 2369: Return dataTable
Line 2370: End Function

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET
Files\MyCompanyMyProject\7eeeedcd\743a3129\App_Co de.zobkgcsa.15.vb Line:
2368

=======================

Any idea why?

I verified all the data, that no pk/fk are violated, etc... Even when I
turn 'enforce constraints' off in the xsd dataset properties it still
fails.



Nov 1 '08 #3
Thanks I got it. Per your suggestion I went over it again. For some reason
a field was marked as a PK where it shouldn't be. Wierd.

THANKS SLOAN!!!
Nov 1 '08 #4
Key word : Anally.

Its always something super small.

"Bobby Edward" <bo***@nobody.comwrote in message
news:Oj**************@TK2MSFTNGP04.phx.gbl...
Thanks I got it. Per your suggestion I went over it again. For some
reason a field was marked as a PK where it shouldn't be. Wierd.

THANKS SLOAN!!!

Nov 3 '08 #5

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

Similar topics

6
by: Ryan | last post by:
I have a query which is quite complex. It's based on a set of data in a complex view which takes the data from several tables. In this complex query, if I allow the various parts of the query to...
1
by: JC | last post by:
I am a newbe to C#, and I am required to enable and disable rows in a listview, depending on certain criteria. e.g. The listview contains - Apples Oranges Grapes I am required to have...
6
by: Kwok | last post by:
Hi All, I want to make the longest string value (it probables more than 300 words.) to more rows to print it using printDocument. How do i do it like WORD that it auto cut string value at...
3
by: Elezar Simeon Papo | last post by:
Hello All, I have a tab separated input file (data.txt) in text format - the file looks like this SCHOOL DEPART1 DEPART2 DEPART3 Harvard Economics Mathematics Physics...
3
by: baka | last post by:
Dear Sir/madam Here i am having some one sql which returns more rows than the required rows after comaparing tables simple sql statement will be lokk like SELECT t.empcd, s.daicd, s.chucd,...
2
by: mmoski | last post by:
I'm doing some data warehousing for this charity and I can't enforce referential integrity. I know there is a value out there that violates it and I was wondering if anybody knows a way to design...
3
by: cookjean | last post by:
I have created a fairly complex view based upon several UNION statements and the view selects exactly the rows that I want if I am in ORACLE SQLPLUS or MS Access. But in Crystal Reports it returns...
3
by: senthilnova | last post by:
hi all i have c# class which calls a stored procedure having insert,update and delete method (using if to switch between them). when i call the SP to EXECUTENONQUER() there is no response from...
9
by: priscillamuis | last post by:
Hi, my database has 4 colums: name, adres phone and fax I'm running this query: SELECT DISTINCT '$sender',MSG = substring ((SELECT RTRIM(name)+','+RTRIM(street)+' t:'+RTRIM(telno)+'...
4
by: MyWaterloo | last post by:
Hey all, I don't know where to go with this Excel question so I thought I would come here. You all have always been able to answer/help me with all my Access questions. I know this is not...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.