Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Failed to enable contraints error?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.


Steve Dussinger
Can someone give me some idea what this error means?

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

I have exactly one row in my database table. The table is as follows:

Column Type Size Allows Nulls
userId int 4 bytes F <--- Key Field
userName char 10 bytes T
userPassword char 10 bytes T

Since there is only one row in the table I'm pretty sure that I can't
possibly be vioating any UNIQUE constraints, and since I only have one
table there sure aren't any foreign keys set up either, so I have to
assume that its a null constraint. But there are no null entries in
the one row in this table.

I select the one row in my database using an ADO.NET dataset (from an
ASP.NET page) and I get this error.

The row in my database is as follows:

userId = 1
userName = myname
userPassword = mypassword.

I can see the contents of my database by using the SQL Server
Enterprise Manager and it shows exactly what I expect, but still I get
this error.

Anyone know what the problem is here?? I'm tearing my hair out on
this.

Thanx,
Steve
Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
Hussein Abuthuraya(MSFT)
Steve,

You included good describtion of the problem but you didn't list the code that caused this error. Can you post the minimum code that recreates the problem indicating what
line of code caused this error?

Also, indicate if this is a SQL Server database or something else.

Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
    
Steve Dussinger
Hussein:

Thanx for the reply, but I figured it out. The problem was my not
understanding the difference between a strongly-typed DataSet vs a
non-typed DataSet.

It turns out that I was modifying the select statement so that it was
only returning some of the columns from the table, and that caused a
conflict with the non-null constraints defined in the table.

Changing the select statement to return all of the columns in the table
solved the problem.

--Steve

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.Data.DataSet




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734