Reputation: 135
I am using typed dataset in asp.net 4.5, but when i am filling datatable using tableadapter and dataset i am getting enforce constraint error.
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.". In dataset there in only one row still i\I am getting this error . Currently i am using
Dataset.EnforceConstraints = false;
but i dont want to use this. so please give me solution for this.
Thanks in advance.
Upvotes: 1
Views: 370
Reputation: 135
First of all thanks for your help. I got the solution. On that composite key, i have removed primary constraint and converted it to unique constraint because there was one nullable column. And there was one problem maxlength of one column was less. I am posting this because it may be useful for someone else in future.
Thanks.
Upvotes: 0
Reputation: 638
please closely look at TDS. i am sure that your TDS contains multiple P.key fields that does not match with your retrn dateset. so please remove one/some of the P.Key from yours TDS by right clicking on the field. and test again. Hope that it will help you.
Upvotes: 0
Reputation: 1460
this error happened due to constraints in the table. If you are using relations in the table it will happened. ie, your table has a fourign key member, you are not allowing add in the child table without an entry in the master table.
in the image there showed a relation. on table2 a column is fourign key of table1. So if you try to insert a value in table2 without an entry in table with same sl_no this error will be shown.
Upvotes: 2