Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I Have four table
Order_Request
Tbl_Printer
Tbl_Monitor
Tbl_CPU

I have a relation FK_Tbl_Order_Request_Tbl_CPU and FK_Tbl_Order_Request_Tbl_Monitor
FK_Tbl_Order_Request_Tbl_Printer

when i try to enter data for moniter in Order_Request its giving me error

SQL
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Tbl_Order_Request_Tbl_CPU". The conflict occurred in database "EHealthInventory1", table "dbo.Tbl_CPU", column 'CPU_ID'.
The statement has been terminated.
Posted
Comments
Prasad Khandekar 3-Jun-13 8:36am    
Hello,

You may be trying to insert a value for CPU_ID column in order_request for which no corresponding record exists in Tbl_CPU.

Regards,
Savalia Manoj M 3-Jun-13 8:39am    
Please first insert record into Tbl_CPU and then insert record into Tbl_Order_Request.
$ultaNn 3-Jun-13 8:41am    
I am trying enter monitor ID in Order_Request at once ,
i can select cpu list, monitor list , printer list from a dropdown . where i can only select one item from one table . when i select one model its giving me error .
gvprabu 3-Jun-13 8:42am    
First you have to insert in "Parent" table, then that Ids only will insert in "Child" tables...
$ultaNn 3-Jun-13 8:45am    
@Savalia : i have data in CPU table , i have cpu id C-101 and so on , monitor ID M-101 and so on .. in the tables ..

i am trying to save ID's in Order_Request from different tables.

1 solution

The error clearly states that there is a conflict with the foreign key constraint. It means you are trying to insert a value that does not exist in the Foreign Key table. In your case the value of "CPU_ID" you are inserting in the table does not exist in "dbo.Tbl_CPU". The foreign key values you insert in a table must exist in their referenced tables.
 
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