Click here to Skip to main content
11,717,883 members (80,801 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL2000 SQL-server-2005 C#2.0 , +
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 2:33am
Prasad Khandekar at 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 at 3-Jun-13 8:39am
Please first insert record into Tbl_CPU and then insert record into Tbl_Order_Request.
Lubnash at 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 at 3-Jun-13 8:42am
First you have to insert in "Parent" table, then that Ids only will insert in "Child" tables...
Lubnash at 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
0 Sergey Alexandrovich Kryukov 849
1 OriginalGriff 215
2 F-ES Sitecore 210
3 Maciej Los 140
4 Jochen Arndt 120
0 Sergey Alexandrovich Kryukov 1,494
1 OriginalGriff 535
2 Maciej Los 529
3 Richard MacCutchan 440
4 CHill60 415

Advertise | Privacy | Mobile
Web03 | 2.8.150901.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