473,836 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 '/MyCompanyMyProj ect' 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.Con straintExceptio n: 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.myoptio nsDataTable = New
dsUsers.myoptio nsDataTable
Line 2368: Me.Adapter.Fill (dataTable) <==== LINE IS IN RED!
Line 2369: Return dataTable
Line 2370: End Function

Source File: c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary ASP.NET
Files\MyCompany MyProject\7eeee dcd\743a3129\Ap p_Code.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 22012

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.c omwrote in message
news:eV******** ******@TK2MSFTN GP02.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 '/MyCompanyMyProj ect' 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.Con straintExceptio n: 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.myoptio nsDataTable = New
dsUsers.myoptio nsDataTable
Line 2368: Me.Adapter.Fill (dataTable) <==== LINE IS IN RED!
Line 2369: Return dataTable
Line 2370: End Function

Source File: c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary
ASP.NET Files\MyCompany MyProject\7eeee dcd\743a3129\Ap p_Code.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.ne twrote in message
news:ev******** ******@TK2MSFTN GP04.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.c omwrote in message
news:eV******** ******@TK2MSFTN GP02.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 '/MyCompanyMyProj ect' 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.Con straintExceptio n: 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.myoptio nsDataTable = New
dsUsers.myopti onsDataTable
Line 2368: Me.Adapter.Fill (dataTable) <==== LINE IS IN RED!
Line 2369: Return dataTable
Line 2370: End Function

Source File: c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary
ASP.NET
Files\MyCompan yMyProject\7eee edcd\743a3129\A pp_Code.zobkgcs a.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.c omwrote in message
news:Oj******** ******@TK2MSFTN GP04.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
2204
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 work on the results of the view (MISView), it can take 15 minutes to run (eek !), however, if I create a temporary table with the data from the view and then use that for the remainder of the query, it runs in approx 20 seconds. Now, I have...
1
4683
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 Apples and Grapes enabled and available for selection, and Oranges must be disabled so that a user cannot select
6
4489
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 space character.
3
24809
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 Stanford Mathematics Physics Berkeley Physics U.C.L.A Biology Genetics
3
2291
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, s.shocd, t.juncd, s.shoname FROM temptbl AS t,shomast AS s WHERE t.shoname=s.shoname;
2
2078
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 a query which will give me the values that violate RI. I'm using Access 97 and I would appreciate your help! Thanks.
3
11159
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 rows that should not be visible through this view. Has anyone else experienced this and what did you to get around this?
3
3030
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 the sqlserver. I too tested the stored proc seperately , it shows NO ROWS AFFECTED and 0 ROWS RETURNED. But the rows get inserted , or updated according to my call.(i found this by checking recs in table).what would be the trouble?? really confusing...
9
1483
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)+' f:'+RTRIM(faxno)+' - ' FROM autodatabase WHERE name LIKE '$keyword%' FOR XML path(''), ELEMENTS),0 ,500) FROM autodatabase I want the first reply to be the first 2 rows of what has been found. I get all the rows with the same keyword in the database.
4
2471
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 exactly kosher asking this in an Access forum... I am trying to create a chart in Excel 07, I am pulling data from multiple sheets (each sheet being a year). Within each sheet is 12 different months worth of data for the corresponding year that each...
0
9825
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9672
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10854
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6981
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4460
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 we have to send another system
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.