Click here to Skip to main content
11,629,371 members (65,710 online)
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 2:33am
Lubnash898
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


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