Click here to Skip to main content
15,896,338 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Exception of type 'System.Web.HttpUnhandledException' was thrown.; The DELETE statement conflicted with the REFERENCE constraint "FK_Table_search". The conflict occurred in database "officen_ac7master", table "dbo.bc_RefineSearchProducts", column 'searchID'.
The statement has been terminated.
how it solve please help me
Posted

1 solution

From the exception, it is quite clear that you are deleting data from one table, which has a reference in another table.

The constraint is FK_Table_search. So check this constraint and find out the related table to which it is related.

The related column is searchID.

After finding the table to which it is related, you need to delete that related record first and then delete from the table you are trying. So, you will need two DELETE queries.

-> First one for Child table/Related table.
-> Second one for the Parent table.
 
Share this answer
 
Comments
Bernhard Hiller 6-May-13 3:46am    
Instead of two DELETE queries, he could also use an ON DELETE CASCADE for the constraint.
Yes that would be good. Can you give me one example how exactly it works ?
I don't know about it. You can also give any reference tutorial, if you have or you can find.

Thanks a lot,
Tadit

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