473,396 Members | 1,859 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,396 software developers and data experts.

delete error

46
Hi all...

I want to delete the 5 years ago's databases and there is an error occur in the line "rs.delete". Below is my code.

The error is:
"Row cannot be located for updating. Some values may have been changed since it was last read."

This error will occur when rs reach the row that it should be deleted. What should I do?? Thanks for help.

Expand|Select|Wrap|Line Numbers
  1.   rs.MoveFirst
  2.  
  3.     Do While (rs.EOF <> True)
  4.         If (DateDiff("yyyy", rs.Fields("dateVar"), Now()) >= 5) Then
  5.     'MsgBox DateDiff("yyyy", rs.Fields("dateVar"), Now())
  6.             rs.delete
  7.         End If
  8.         'rs.Update
  9.         rs.MoveNext
  10.     Loop
Jun 29 '07 #1
5 1251
Dököll
2,364 Expert 2GB
"Row cannot be located for updating. Some values may have been changed since it was last read."
Expand|Select|Wrap|Line Numbers
  1.   rs.MoveFirst
  2.  
  3.     Do While (rs.EOF <> True)
  4.         If (DateDiff("yyyy", rs.Fields("dateVar"), Now()) >= 5) Then
  5.     'MsgBox DateDiff("yyyy", rs.Fields("dateVar"), Now())
  6.             rs.delete
  7.         End If
  8.         'rs.Update
  9.         rs.MoveNext
  10.     Loop
Greetings, berry!

Are you able to read the data you're hoping to update/delete?
Jun 29 '07 #2
berry
46
Greetings, berry!

Are you able to read the data you're hoping to update/delete?
Hi Dokoll,
Thank you for your reply.
Ya, it can read the data. It can calculate the date different within the date in database and today's date. So it means that the row can be read right??
But when reach to the rs.delete, the error will occur.
I wonder what's the problem over there..
Hope can get the answer..
Thanks...
Jun 29 '07 #3
Killer42
8,435 Expert 8TB
Doesn't it automatically move to the next record after deleting? If so, then you'd need to skip the MoveNext. Otherwise, I don't know what the problem is. Perhaps the underlying data was changed by another process while you were moving through this recordset.
Jun 29 '07 #4
Killer42
8,435 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. rs.MoveFirst
  2. Do While (rs.EOF <> True)
  3.   If (DateDiff("yyyy", rs.Fields("dateVar"), Now()) >= 5) Then
  4.     'MsgBox DateDiff("yyyy", rs.Fields("dateVar"), Now())
  5.     rs.delete
  6.   End If
  7.   'rs.Update
  8.   rs.MoveNext
  9. Loop
I was just thinking, wouldn't it be better to use a simple delete query to do this? Something like:
DELETE FROM tablename WHERE dateVar >= #your-cutoff-date#
Jun 29 '07 #5
berry
46
I was just thinking, wouldn't it be better to use a simple delete query to do this? Something like:
DELETE FROM tablename WHERE dateVar >= #your-cutoff-date#
Hi killer42,
I can't use this code because i need to compare to the date in the database, I don't know the cut-off-date.
Jun 29 '07 #6

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

Similar topics

2
by: foo | last post by:
I'm creating a debug class called debug_mem_allocation for the purpose of finding memory leaks. I used macro's to replace the new and delete operators. My problem is with trying to replace the...
1
by: Douglas Peterson | last post by:
class Allocator { public: virtual void * Alloc(size_t) = 0; virtual void * Free(void*) = 0; }; class Object { public:
2
by: Radde | last post by:
Hi all, #include<iostream> using namespace std; class A{ private: int* iArray; int size; public:
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
4
by: Susan Bricker | last post by:
I have a command button on a form that is supposed to Delete the record being displayed. The record is displayed one to a form. The form is not a Pop-Up nor is it Modal. Tracing the btnDelete...
3
by: John Rivers | last post by:
Hello, I think this will apply to alot of web applications: users want the ability to delete a record in table x this record is related to records in other tables and those to others in...
10
by: junw2000 | last post by:
Hi, Below is a small code about memory allocation and deallocation. #include <cstdlib> #include <iostream> using namespace std; class X { public: void* operator new(size_t sz) throw (const...
24
by: biganthony via AccessMonster.com | last post by:
Hi, I have the following code to select a folder and then delete it. I keep getting a Path/File error on the line that deletes the actual folder. The line before that line deletes the files in...
12
by: Premal | last post by:
Hi, I tried to make delete operator private for my class. Strangely it is giving me error if I compile that code in VC++.NET. But it compiles successfully on VC++6.o. Can anybody give me inputs...
16
by: busterbaxter | last post by:
Hi All, I got a multiple delete working here but for some reason I occassionally get this error. The way the delete works is there is a text box where the user enters the quantity to delete. If...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.