Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When trying to insert a row into my databse table I am getting this error:-

SQL
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_table_table". The conflict occurred in database "database", table "dbo.table", column 'columname'.
The statement has been terminated.


Please could someone advise me on what the issue is likely to be. Thanks in advance for your time.
Posted
Updated 6-Sep-11 21:16pm
v2
Comments
Wayne Gaylard 7-Sep-11 3:17am    
Please take a look at how I rephrased your question and title. In future please try and give as much info as possible.

Well, it seems pretty obvious that you are trying to Insert a row into a table that has a foreign key constraint and you are not complying with that constraint. Most likely you are inserting a row with an illegal value for another tables primary key that is linked to the original table.
 
Share this answer
 
Check your table structure and constraints.
Then check are you passing valid values to insert statement.
Try to execute query on database.
 
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