Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

I'm developing a windows application that uses query to fill crystal reports.
I'm getting the following error: "Failed to enable constraints. One or more rows contain values violating non null unique or foreign-key constraints"

Here is the code

SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd, DBConnection.GetSqlConnction());
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "Machines");


I'm getting this exception in the last line.

note: The code works when I use a table that does not have any relations with other tables.

Thank you
Posted
Updated 1-Sep-10 22:49pm
v2
Comments
senguptaamlan 2-Sep-10 4:49am    
let me know the content of "cmd". I believe thats a SQLCommand object...please provide the code..
Dalek Dave 2-Sep-10 4:50am    
Edited for Grammar and Readability.

See,

Did you specified the Select Query properly.

Just try

SELECT * FROM TABLE, it will work I think.

If you dont create relationship in the dataset, it will not create any problem.:rose:
 
Share this answer
 
ok..your code listing doesnt really show much about the error..but I would suggest you try this approach..

1.create a stored procedure of the original query you're using to make your dataset.

2. Now in the crystal reports design view, using the database tab, refer your datasource to the stored procedure of the database and pool your data feilds from the parameters of the stored proc.

..

Now the rest is just simple crystal report designs..blah blah..

And it should be working, I believe :)
 
Share this answer
 
thank u for fast answers but iam sure that the query is written correct also there are no relations in the dataset, and also i'm beginner i dont know how to write stored procedures.

so plz could anyone help me to solve this error
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900