ForeignKeyConstraint requires the child key values to exist in the parent table!
-
Is the subject line too long? Probably. I'm experiencing an issue with my dataset that seems to be telling me that the values for a foreign key in my child table does not exist within the parent table. As far as I can see, the value does exist. This happens when I try to fill a datagridview using a tableadapter. If the program throws the exception as normal I get the usual "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." If I use a try/catch around the query it fills the datagridview but gives me a red warning sign that reads "ForeignKeyConstraint [ForeignKey] requires the child key values (value) to exist in the parent table." Has anyone come across this particular issue? Where can I usually find the properties for foreign key contraints? Any help would be hugely appreciated! (I'm using the generic Fill query created for tables in sqlserver.)
-
Is the subject line too long? Probably. I'm experiencing an issue with my dataset that seems to be telling me that the values for a foreign key in my child table does not exist within the parent table. As far as I can see, the value does exist. This happens when I try to fill a datagridview using a tableadapter. If the program throws the exception as normal I get the usual "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." If I use a try/catch around the query it fills the datagridview but gives me a red warning sign that reads "ForeignKeyConstraint [ForeignKey] requires the child key values (value) to exist in the parent table." Has anyone come across this particular issue? Where can I usually find the properties for foreign key contraints? Any help would be hugely appreciated! (I'm using the generic Fill query created for tables in sqlserver.)
-
Is the subject line too long? Probably. I'm experiencing an issue with my dataset that seems to be telling me that the values for a foreign key in my child table does not exist within the parent table. As far as I can see, the value does exist. This happens when I try to fill a datagridview using a tableadapter. If the program throws the exception as normal I get the usual "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." If I use a try/catch around the query it fills the datagridview but gives me a red warning sign that reads "ForeignKeyConstraint [ForeignKey] requires the child key values (value) to exist in the parent table." Has anyone come across this particular issue? Where can I usually find the properties for foreign key contraints? Any help would be hugely appreciated! (I'm using the generic Fill query created for tables in sqlserver.)
I came across this error to when I thought the parent value did exist. For me the solution was that I had to make sure that the ParentColumns and ChildColumns for the constraint listed the columns in the same order.