6 Replies - 243 Views - Last Post: 21 February 2019 - 01:30 AM Rate Topic: -----

#1 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 87
  • Joined: 30-August 15

Can't submit duplicate data in Access.

Posted 17 February 2019 - 08:35 PM

I created a program in VB.NET that allows the user to submit information, and then it goes to a Microsoft Access file.

I get this error when I try to submit duplicate data:

System.Data.OleDb.OleDbException: '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.'

How do I allow duplicate data? [Not sure if this is a VB problem or a Access problem.]

Is This A Good Question/Topic? 0
  • +

Replies To: Can't submit duplicate data in Access.

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14854
  • View blog
  • Posts: 59,272
  • Joined: 12-June 08

Re: Can't submit duplicate data in Access.

Posted 17 February 2019 - 08:49 PM

You would need to change the db table keys.. though that is a bad idea. Perhaps fix the code and dont have duplicates keys.
Was This Post Helpful? 1
  • +
  • -

#3 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 87
  • Joined: 30-August 15

Re: Can't submit duplicate data in Access.

Posted 18 February 2019 - 07:15 AM

View Postmodi123_1, on 17 February 2019 - 08:49 PM, said:

You would need to change the db table keys.. though that is a bad idea. Perhaps fix the code and dont have duplicates keys.


How would I change the db table keys (and why is that a bad idea)? The program will have duplicate information, as I ask for the first and last name, among other choices.

If itís still a bad idea to change te db table keys, then where/what in the code should I change?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14854
  • View blog
  • Posts: 59,272
  • Joined: 12-June 08

Re: Can't submit duplicate data in Access.

Posted 18 February 2019 - 08:06 AM

You would change the keys in the actual database. So crack it open in Access.

Why is it bad? Simple - how do you know what to update or get if there is no unique keys? If you had three entries labeled 'RED' but you wanted to update only one how would you go about that? You wouldn't unless you had a unique key associated with each row. It's a core principle of relational DBs.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6737
  • View blog
  • Posts: 27,741
  • Joined: 12-December 12

Re: Can't submit duplicate data in Access.

Posted 19 February 2019 - 03:05 AM

Go into Access and check the table indexes and relationships. The field(s) at issue are either the primary key or a unique index on one or more fields. If you have a unique index on one or more fields that shouldn't be there then remove it.

An index can still occur on firstname/lastname but it should not be a unique index.
Was This Post Helpful? 1
  • +
  • -

#6 geos59   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 87
  • Joined: 30-August 15

Re: Can't submit duplicate data in Access.

Posted 20 February 2019 - 07:03 PM

View Postandrewsw, on 19 February 2019 - 03:05 AM, said:

Go into Access and check the table indexes and relationships. The field(s) at issue are either the primary key or a unique index on one or more fields. If you have a unique index on one or more fields that shouldn't be there then remove it.

An index can still occur on firstname/lastname but it should not be a unique index.


I removed the Primary Key and am now able to submit multiple data accordingly - thanks!
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6737
  • View blog
  • Posts: 27,741
  • Joined: 12-December 12

Re: Can't submit duplicate data in Access.

Posted 21 February 2019 - 01:30 AM

Removed the primary key?! Ah well, as long as you are happy...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1