Click here to Skip to main content
15,942,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 3 tables namely transemployee, refDesignation and refEmployeetype table. the transemployee table is the main table where i have columns like empid,firstname,middlename,lastname,entrepriseid,mailid,designationId,employeetypeid,createdon,modifiedon and isactive columns.

the other tables have designationid,designation(refdesignation table) and employeetupeid and employeetype..

in the trans emplyee table empid is d primary key and in refemployeetype and refdesignation table designationid and employeetypeid is the primary key

these act as foreign keys in transemployee table.

now if i ngive a insert query like this i get the following error:

INSERT INTO [UserManagementDB].[dbo].[TransEmployee]

i get hte error as The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TransEmployee_RefDesignation". The conflict occurred in database "UserManagementDB", table "dbo.RefDesignation", column 'DesignationId'.
Updated 12-Dec-12 23:27pm

First insert designationid in designation table and employeetupeid in employeetypetable then insert the value to TransEmployee table with same designationid & employeetypeid
Share this answer

This error occurred due to the empty record in the parent table whose ID is foreign keyed in the TransEmployee table.

So 1st of all make an entry in the parent tables (designation, employeetype ). Then only the foreign key will be available to your 3rd table (TransEmployee).

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