This is the message that i get when trying to assign keys when creating diagrams in visual express:
'tbh_Polls' table saved successfully
'tbh_PollOptions' table
- Unable to create relationship 'FK_tbh_PollOptions_tbh_Polls'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_tbh_PollOptions_tbh_Polls". The conflict occurred in database "C:\USERS\STICKER\DOCUMENTS\MY WEB SITES\PERCSHARP\APP_DATA\ASPNETDB.MDF", table "dbo.tbh_Polls", column 'PollID'.
PollID is my primary key in tbh_Polls
And PollID is in tbh_PollOptions table
No matter what I do, I get this message, I'm Lost!
Help plz.
Thanks
hi,
It seems to me the underlying tables are already populated, and there's a row (at least) in the referencing table (tbh_PollOptions) not satisfying the relationship you like to enforce..
you could define the foreign key constraint WITH NOCHECK, meaning the already inserted rows will not be validated at constraint creation, so that the exception will not raise.. but you stay with invalid relationship in the underlying table to the referenced table.. this option, WITH NOCHECK, should be used when you already know the relationship is already satified and you do not have "bad data"..
regards
|||So in order for me to create the relationship is to get rid of the data i have in these 2 tables and then create the fk?
That's not a proble because i only populated them with a sample data and not a real thing. I'll try that first and see if it will work.
Thanks a lot.
|||IT WORKED
YEAAAAHHHHHH!
Thanks a milion!
You know, i only started with programing 2 months ago and i'm already hooked, especially when there are people who happen to know what's causing the bugs. Untill i learn more i'll have to ask often. so thanks!
|||hi,
Kliker wrote:
So in order for me to create the relationship is to get rid of the data i have in these 2 tables and then create the fk?
no, you have to get rid of "bad data", that's to say the row(s) where the referencing column does/do not match the referenced table values... or fix it/them..
That's not a proble because i only populated them with a sample data and not a real thing. I'll try that first and see if it will work.
Thanks a lot.
you're welcome..
regards
No comments:
Post a Comment