将行插入数据库表时出现问题 [英] Problem inserting row into database table

查看:127
本文介绍了将行插入数据库表时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试在我的数据库表中插入一行时,出现此错误:-

When trying to insert a row into my databse table I am getting this error:-

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.

推荐答案

好吧,很显然,您正在尝试将行插入具有外键约束的表中,并且您正在不遵守该约束.很可能您要为链接到原始表的另一个表主键插入具有非法值的行.
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.


检查表的结构和约束.
然后检查是否将有效值传递给insert语句.
尝试对数据库执行查询.
Check your table structure and constraints.
Then check are you passing valid values to insert statement.
Try to execute query on database.


这篇关于将行插入数据库表时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆