开发者

Not able to add column value

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开发者_如何学C 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.


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!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜