p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > C# and C > C# 1.0 > C#
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 16th, 2006, 03:39 PM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 16th, 2006, 10:25 PM
op op is offline
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are there two or more empty x in table xpto?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old July 17th, 2006, 06:59 PM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. To empty values (DBNull.Value).

Thanks.
Fred
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 18th, 2006, 09:42 PM
op op is offline
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old September 26th, 2006, 05:30 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old July 31st, 2009, 08:04 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with dataset autoincrement column Jayaram ADO.NET 0 December 4th, 2006 03:13 PM
Vertically Constrain GridView wirerider ASP.NET 2.0 Basics 3 February 6th, 2006 06:53 PM
Unique values from a dataset gbuller Pro VB.NET 2002/2003 3 September 27th, 2004 01:17 PM
dataset column not in data base table gbuller ADO.NET 4 August 18th, 2004 11:18 PM
duplicate nulls in a column with unique constraint defiant SQL Server 2000 3 October 22nd, 2003 02:58 AM



All times are GMT -4. The time now is 01:53 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc