无效的约束异常 [英] Invalid Constraint Exception
问题描述
我在尝试构建程序时遇到此错误。
ForeignKeyConstraint FK_Game_Assists要求子键值(1)存在于父表中。
ForeignKeyConstraint FK_Game_Assists requires the child key values (1) to exist in the parent table.
这是什么意思,我该如何解决??
What does it mean and how do I fix it.?
推荐答案
这意味着存在关系数据库约束错误。
It means that there is a relational database constraint error.
我将在代码中的某处假定数据集正在创建/ datatable等,并在某处添加约束。这将建立两个表之间的关系。
I will presume somewhere in your code a dataset/datatable etc is being created and somewhere a constraint is being added. This sets up a relationship between two tables.
表A是主表,表B是外表
Table A is the primary table and Table B the foreign table
让我们说表A有一个GameID列,表B有一个列,它的名字可以是anyignign但是我们将其称为GameID。
Lets say table A has a GameID column and so does Table B has a column it's name can be anythign but we will call it GameID.
ForeignKeyConstraint表示表B(外表)中输入的任何GameID必须存在于表中A(父)
A ForeignKeyConstraint says any GameID entered into Table B (foreign table) MUST exist in Table A (parent)
似乎正在创建一个约束,其中GameID列确实存在于TableB上但是表A中不存在列GameID
It appears a constraing is being created that where the GameID column does exist on TableB but the column GameID does not exist on Table A
如果不清楚,绘制两个表可以帮助可视化问题。可能是在创建约束时指定的列名称拼写错误,这样的简单。
If that's not clear , drawing the two tables can help visualise the problem. It may be the column name specified in the creation of the constraint is mis spelled, something simple like that.
这篇关于无效的约束异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!