Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
SQL
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_lms_newreg_lms_Refferal". The conflict occurred in database "SSS_lms", table "dbo.lms_Refferal", column 'Refferal_Id'.
The statement has been terminated.


this is an exception which i get sometimes only as sometimes it works correctly!

I dont understand why this happen. Please suggest.
Posted
Updated 18-Apr-10 20:57pm
v2

This happens because, you must be trying to insert a value in table lms_newreg where Refferal_Id that does not exists in lms_Referal.

At times, what you try to insert for that key, the value exists so no error. But sometime the value used for it is not found in the lms_refferal table and thus the error.
 
Share this answer
 
A foreign key (FK) is a column or combination of columns that is used to establish and enforce a link between the data in two tables.
Now my friend carefully look at ur tables as ur doin some sort of errors while data entry as the data which u must be addin must not be present in the other table whos reference ur giving so please check out ur tables or use a combobox during form or page load event reterive the desired column from the database and ur done...
no erors no exceptions and no serious data entry errors because the data will already be present in the combobox when ur application loads

also read the Referential Integrity[^]in SQL for better understanding

Do rate my answer once u find it useful

Thanks & Regards
Radix :rose:
 
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