Click here to Skip to main content
11,928,786 members (54,518 online)
Rate this:
Please Sign up or sign in to vote.
I Have four table

I have a relation FK_Tbl_Order_Request_Tbl_CPU and FK_Tbl_Order_Request_Tbl_Monitor

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

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 3-Jun-13 3:33am
Prasad Khandekar 3-Jun-13 8:36am

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

Savalia Manoj M 3-Jun-13 8:39am
Please first insert record into Tbl_CPU and then insert record into Tbl_Order_Request.
Lubnash 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...
Lubnash 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 3 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100