无法添加列值

发布于 2024-09-01 10:15:28 字数 510 浏览 3 评论 0原文

我有一个项目,其中包含这些 shedule 表会话列中的 4 个表,我无法添加值,该表包含

来自两个表的三个外键(其中单个表此处有两个外键)我在这里添加了值..任何一个 对此有任何想法..实际上我的意图是删除错误“插入语句与外键约束sql server冲突”

表Shedule包含会话号作为主键,,它在Q&中用作外键;一个表格。表格问答包含问题编号 作为主键。表 Employee 包含 Employeeid 作为主键,在 Q&A 表中用作外键两次 与 Shedule 表中的键相同。表主题包含 Topicid 作为主键,在 Shedule 表和 Q&A 表中用作外键 这里我的问题是我无法在 Shedule 表中添加会话列的值(这是主键) 第二是每当我在问答表中插入值时,我都会收到这样的错误 错误消息:INSERT 语句与 FOREIGN KEY 约束“FK_QandA_Schedule”冲突。冲突发生在数据库“secon”、表“dbo.Schedule”、列“Session_No”中。 该声明已终止。

I have project which contain 4 tables among these shedule table Session column i am not able to add vaue,,this table contain

three foriegn key from two tables(in which single table has two foreign keys here) i added values here..Any one
has any idea about this..Actually my intention is to remove the error "the insert statement conflicted with the foreign key constraint sql server"

Table Shedule contains session number as primary key,,it is used as foreign key in Q&A table.Table Q&A contains Question num
as primary key .Table Employee contain Employeeid as primary key which is used as foriegn key in Q&A table two times foriegn
key as in Shedule table .Table Topic contain Topicid as primary key which is used forign key in Shedule table ans Q&A table
Here my problem is i cant add values for session column in Shedule table(which is a primary key)
second is whenever i insert values in Q&A table i am getting error like this
Error Message: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_QandA_Schedule". The conflict occurred in database "secon", table "dbo.Schedule", column 'Session_No'.
The statement has been terminated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

女皇必胜 2024-09-08 10:15:28

插入语句与
sql server 的外键约束

显然,您正在尝试将一些值插入到引用表中不是有效值的外键字段之一。

您说您有三列 - 根据它们引用的表检查每一列 - 应该不难找出哪一列无效 - 然后使用有效值。这就是引用完整性的全部要点 - 确保您不会将无效数据插入表中!

the insert statement conflicted with
the foreign key constraint sql server

Obviously, you're trying to insert some value into one of the foreign-key fields that isn't a valid value in the referenced table.

You say you have three columns - check each of those against the tables they reference - shouldn't be too hard to figure out which one is not valid - and then use a valid value instead. That's the whole point of referential integrity - make sure you don't insert invalid data into your tables!

无悔心 2024-09-08 10:15:28

错误的意思就是它所说的。也就是说,它在父表中没有根据该 id 的列。

更具体地说,请向我们展示表格和 INSERT 语句。

更新:如果我没说错的话:

1)你尝试在表Shedule中插入一行,对吗?

如果是这样,您需要在表Employee中拥有Employeeid,并在表Topic中拥有Topicid,您可以正在尝试插入。
根据错误消息,我想您没有有效的问答外键值。这意味着,您尝试在 INSERT 语句中添加的 Q&A 外键值必须存在于 Q&A 表中。

2) 您尝试在表问答中插入一行?

对于此表,您需要具有有效的 Employeeid(其中 2 个?)、TopicidSession_number

PS但是如果您不向我们展示 INSERT 语句,我无法判断您的问题是什么。

The Error means what it says. That is, it doesn't have a column according to that id in a parent table.

To be more specific, please show us tables and INSERT statement.

UPDATE: If I got you right:

1) You try to INSERT a row into table Shedule, right?

If so, you need to have the Employeeid in table Employee and a Topicid in table Topic, that you're trying to INSERT.
I suppose, you don't have a valid Q&A foreign key value, according to error message. That means, the Q&A foreign key value you're trying to add in your INSERT statement must exist in Q&A Table.

2) You try to INSERT a row into table Q&A?

For this table you need to have valid Employeeid (2 of them?), Topicid and Session_number.

P.S. But I can't tell what's your problem if you don't show us INSERT statements.

晨敛清荷 2024-09-08 10:15:28

我使用了级联规则。暂时有效,但不知道后果。

I used a Cascade rule. It's working temporarily, but I don't know the consequences.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文