Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL2000 SQL-server-2005 C#2.0 , +
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
 
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
Lubnash838
Comments
Prasad Khandekar at 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 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
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 370
1 Sergey Alexandrovich Kryukov 329
2 BillWoodruff 235
3 Afzaal Ahmad Zeeshan 209
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 3 Jun 2013
Copyright © CodeProject, 1999-2014
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