Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 16th, 2003, 10:10 PM
kaz kaz is offline
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to change to "Duplicates OK"?

I got an error message: "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again. "

The SQL statement is:
string UserProjectPSQL = "INSERT INTO UserProject (UserID, ";
UserProjectPSQL += @"ProjectID, CreateDate) ";
UserProjectPSQL += @"VALUES (" +UserID+ ", " +intProjectID+ ", ";
UserProjectPSQL += @"'" +DateTime.Now.ToString()+ "')";

The UserProject table contains UserID as PK(Duplicates OK), ProjectID as PK(Duplicates OK), CreatedDate, and UserTypeCode. So, those values should be OK with duplicate values. How can I change the UPDATE statement?

Thanks,

  #2 (permalink)  
Old December 17th, 2003, 02:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Is this database Access?

By 'UserID as PK(Duplicates OK), ProjectID as PK(Duplicates OK)' do you mean the User ID and ProjectID are together a primary key? If so, then by definition, a primary key cannot have duplicates, despite what Access might have led you to think you may have set the column(s) to be.

If a column or columns are a primary key, then they are the unique means to identify a given row, so duplciates cannot be allowed, otherwise how would you know which one row the key referred to?

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
  #3 (permalink)  
Old December 17th, 2003, 11:44 PM
kaz kaz is offline
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!!!



Similar Threads
Thread Thread Starter Forum Replies Last Post
Yes to duplicates MMJiggy62 Beginning VB 6 3 July 14th, 2006 11:51 AM
duplicates and unique sheba0907 SQL Language 6 July 3rd, 2006 02:43 PM
DUPLICATES NOT ALLOWED codedriller General .NET 9 July 27th, 2004 03:05 PM
Deleting Duplicates ioates SQL Server 2000 5 August 31st, 2003 10:18 AM
Duplicates ashley_y Access 11 August 14th, 2003 03:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.