473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

SQL Update Key Violation

Hi, I am trying to run an SQL update query but out of the 9 records it should be updating, it updates one and then says: "Database can't update all the records in the update query. 8 fields weren't updated due to key violations". The SQL statement is below:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL ("UPDATE [Track] SET [digital] = False, [url] = '', [Valid Path] = False WHERE [Artist] LIKE [Artiststore] AND [Album] LIKE [Albumstore]")
  2.  
The access help didn't have anything on key violations...is it a problem with primary keys or something?
Feb 23 '08 #1
4 2779
puppydogbuddy
1,923 Expert 1GB
Hi, I am trying to run an SQL update query but out of the 9 records it should be updating, it updates one and then says: "Database can't update all the records in the update query. 8 fields weren't updated due to key violations". The SQL statement is below:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL ("UPDATE [Track] SET [digital] = False, [url] = '', [Valid Path] = False WHERE [Artist] LIKE [Artiststore] AND [Album] LIKE [Albumstore]")
  2.  
The access help didn't have anything on key violations...is it a problem with primary keys or something?
In my experience, this problem can occur when the foreign key index on the many side of a one to many relation between 2 tables is set to no duplicates allowed, when it should be set to duplicates allowed. So check the index property setting in the foreign key table.
Feb 23 '08 #2
NeoPa
32,556 Expert Mod 16PB
It would appear that one of [digital], [url] or [Valid Path] is defined as not allowing duplicates. Check out your table definition.
Feb 26 '08 #3
Cheers NeoPa and puppydogbuddy, the URL field was set to Yes (No Duplicates). But I don't understand why that caused the problem because the query should overwrite the URL field regardless of what data it contains shouldnt it?

It would appear that one of [digital], [url] or [Valid Path] is defined as not allowing duplicates. Check out your table definition.
Feb 26 '08 #4
NeoPa
32,556 Expert Mod 16PB
The query acted on the first record and set the [url] field to an empty string (''). When it came to the second record it tried to do the same thing. As there was already a record in the table with a [url] field with that same value ('') it could not be updated as that would involve adding a duplicate entry for that index. All subsequent records suffered from the same problem - hence only one was correctly updated.Does that make better sense?
Feb 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: al | last post by:
Greetings, In the customers table in Northwind db, one can update PK (customerid) and all other fields in the same table. My question is how can you do this in the udpate stat. That is, if one...
2
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the...
4
by: Reney | last post by:
I have a very weird problem in updating my datagrid. Please help me to solve it. The datagrid is tied to a dataset table with five columns. Three of them are primary key and the other two columns...
9
by: Geraldine Hobley | last post by:
Hello I'm getting the above mentioned error in my applicatio I have a datagrid bound to a datasource like s MyDatagrid.DataSource = Mydataset.Tables(Order) - this all works fine However I...
2
by: D. Dante Lorenso | last post by:
I'm trying to build a table that will store a history of records by enumerating the records. I want the newest record to always be number ZERO, so I created a trigger on my table to handle the...
6
by: Tom Allison | last post by:
I seemed to remember being able to do this but I can't find the docs. Can I run a sql query to insert new or update existing rows in one query? Otherwise I have to run a select query to see if...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
11
by: John | last post by:
Hi I had a working vs 2003 application with access backend. I added a couple fields in a table in access db and then to allow user to have access to these fields via app I did the following; ...
0
by: robsjonathan | last post by:
hello world, i have two tables stock and sales where one to many relationship is created. The join type is " 2: include all records from stock table and only those from sales where the joined...
2
by: lairpr74 | last post by:
I am trying to update the managers name in active directory with an application I got that updates active directory. I been strugling with this for a few weeks now and couldn't find the best way...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.