|
|
 |
| C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

July 16th, 2006, 03:39 PM
|
|
Registered User
|
|
Join Date: Feb 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
DataSet Column with Unique Constrain Problem
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
|

July 16th, 2006, 10:25 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Are there two or more empty x in table xpto?
|

July 17th, 2006, 06:59 PM
|
|
Registered User
|
|
Join Date: Feb 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes. To empty values (DBNull.Value).
Thanks.
Fred
|

July 18th, 2006, 09:42 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
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?
|

September 26th, 2006, 05:30 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

July 31st, 2009, 08:04 PM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You can't have unique column that is also blank, it makes no sense. More than one blank entry is not unique so that explains the error. It's Microsofts fault for allowing it really.
Why would you want a unique column but leave it blank anyway? Seems pointless. 
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |