|
Subject:
|
DataSet Column with Unique Constrain Problem
|
|
Posted By:
|
niceFEPF
|
Post Date:
|
7/16/2006 2:39:32 PM
|
Hello.
I created a DataSet with a few tables. One of them contains a column that is not required but it is unique.
xpto.Tables["a"].Columns["x"].AllowDBNull = true; xpto.Tables["a"].Columns["x"].Unique = true;
Since this column is not required, empty values can be added. I use DBNull.Value as empty values.
In this case, when I add to rows with empty x column, I get the following error:
Column x is constrained to be unique. Value '' is already present.
The DataBase I use is Access. There I have no problems because I can say that I do not accept Duplicates, and when I add two rows with an empty x I get no errors.
Any ideas?
Thanks for your help. Fred
|
|
Reply By:
|
op
|
Reply Date:
|
7/16/2006 9:25:01 PM
|
Are there two or more empty x in table xpto?
|
|
Reply By:
|
niceFEPF
|
Reply Date:
|
7/17/2006 5:59:37 PM
|
Yes. To empty values (DBNull.Value).
Thanks. Fred
|
|
Reply By:
|
op
|
Reply Date:
|
7/18/2006 8:42:57 PM
|
quote: Originally posted by niceFEPF
Yes. To empty values (DBNull.Value).
Thanks. Fred
The Column x must be unique but you used two empty values.Right?
|
|
Reply By:
|
kmoloney
|
Reply Date:
|
9/26/2006 4:30:13 AM
|
Did you check to make sure that the dataset configuration matches the database config? Sometimes I've found that the ds will need updating for various reasons. Make sure the ds also has DBNull set to true.
|