Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 error:Failed to enable constraints. One or more ro

Author  Topic 

debradeng
Starting Member

46 Posts

Posted - 2006-11-30 : 19:36:35
I got such an error message when I used stored procedure to get data from DB,"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

here is the code:
......
try{

username = (int)Session["username"];

XTableAdapter xTableAdapter = new XTableAdapter;

data view dv = null;

if (Request.QueryString.HasKeys() )
{ }
else
{

dv = (DataView)XTableAdapter.method_x(username).DefaultView;

lblMSG.text = dv.Table.Rows[i].ItemArray.GetValue(4).ToString();
... ...
}
catch{ ex.message;}

Anybody know how to resolve this problem?


harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-01 : 00:07:15
Problem is not in the front-end code, you have to look carefully at the back-end SP (if any). Also, try to run the SP/query in the QA to see the exact location of the problem.

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-12-01 : 00:25:37
I don't see where any calls to sql server are being made here. maybe it's in the ... part.

also, the "catch {ex.message}" part is very strange. I doubt that even compiles.


SqlSpec: a fast and comprehensive data dictionary generator for
SQL Server 2000/2005, Analysis Server 2005, Access 97/2000/XP/2003
http://www.elsasoft.org
Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-12-01 : 01:29:27
To Jezemine,catch{ex.message}build succeeded and even display the error message above.
To Harsh Athaly,I guess you are right.But back-end SP works properly in Sql server management studio and can even get the result.Do you have any advice?

Thank you for your replies!
Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-12-01 : 01:33:02
The code above : method_x() get a dataset from DB by using SP.I tried to use Dynamic sql to replace the sp,but still occured the same error.It is really wired,because the query works well in QA.

Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-12-01 : 01:34:27
The code above : method_x() get a dataset from DB by using SP.I tried to use Dynamic sql to replace the sp,but still occured the same error.It is really wired,because the query works well in QA.

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-01 : 04:03:40
Are you using DataSet?

Check the below link:

[url]http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=364416&SiteID=1[/url]



Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-12-01 : 06:30:12
To Harsh Athalye,I think I find the anwser,thank you so much!
Go to Top of Page
   

- Advertisement -