Run-time error: -2147217864 (80040e38)
The specified row could not be located for updating. Some values may have
been changed since it was last read.
The situation is as follows:
Field in a shared table is being updated using Microsoft Access 2003.
Table is also accessed in a query in the application which receives the
error message above.
I am using VB6 SP6 and ADO 2.6 SP2.
The code used to open the table in the VB app is as follows:
Public adoConn As ADODB.Connection
Public adoIngestHost As ADODB.Recordset
Set adoConn = New ADODB.Connection
adoConn.CursorLocation = adUseClient
adoConn.Open "File Name=" & gstrUDLFileName
' Note the Provider specified in the UDL file is: Microsoft Jet 4.0 OLE
DB Provider
' Access permissions are Share Deny None
' Set up SQL command to retrieve data
strSQL = ""
strSQL = strSQL & "SELECT * from IngestHost "
strSQL = strSQL & "WHERE (((IngestHost.Hostname)='" & HostIdStr & "'))"
Set adoIngestHost = New ADODB.Recordset
adoIngestHost.Open strSQL, adoConn, adOpenKeyset, adLockOptimistic
' other code
adoIngestHost!HostLocation = "prog"
adoIngestHost.Update
' The .Update throws the following error information into the
connections error collection:
Err.Number (hex) 80040E38
Err.Description Row cannot be located for updating. Some
values may have been changed since it was last read.
Err.NativeError 32
Err.Source Microsoft Cursor Engine
Now, I am not opposed to adding some code to handle the error and
select/warn about the conflicting values, but everything I tried to recover
from the error doesn't seem to work.
In the Error routine, when I look at the .Status of each of the fields in
the recordset, they show a code of zero (no error).
When I print out the .Value, .OriginalValue and .UnderlyingValue for the
field, they all show the same value ("prog"), although the value I entered
from Access is "test".
I've tried this with CursorType = adOpenDynamic and adOpenStatic with the
same results. I also tried it with a server side cursor, but that prevents
me from doing .Sort's of the recordset elsewhere in the code.
I also looked at the .Status field value both before and after the update in
the program, but it still always shows 0.
I tried inserting the following line before I set the value in the database:
adoIngestHost.Resync adAffectCurrent, adResyncAllValues
It throws the following error:
Err.Number (hex) 80004005
Err.Description Insufficient key column information for
updating or refreshing
Err.NativeError 1007
Err.Source Microsoft Cursor Engine
None of the hits I found on MSDN or google seem to address this problem.
Am I missing some limitiation of the Jet Engine as a OLEDB provider? Will I
have similar problems if I upgrade to MSDE or SQL Server? Any help would be
appreciated. Please send any responses to the newsgroup.
Thanks.
Ken
Thank you for the response. Regarding on the issue,we're
finding proper resource to assist you and we will update as soon as posible.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when multiple users are updating same
row simultaneously, an error will be generated which says "The specified
row could not be located for updating. Some values may have been changed
since it was last read." If there is any misunderstanding, please feel free
to let me know.
This is a typical concurrency error. Since you have set the lock type to
Optimistic Lock, the data in the row will only be locked during update. So
if the cursor is at client side, the Recordset will not know that data has
been changed since it was get from the database.
In this case we can try to use the server side cursor and open a dynamic
cursor instead. When data has been changed by other users, the changes will
be visible to us. Or we can also try to use a Pessimistic lock. When other
users are making changes to certain data, that row will be locked until
updating is finished.
If a server side cursor prevents you from using the Sort property, could
you use the ORDER BY and WHERE clause in SQL instead?
HTH.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Based on my research, Jet 4.0 OLE DB provider doesn't support the
OriginalValue and UnderlyingValue properties. However, SQLOLEDB provider
only supports these properties with a server side cursor. The locking issue
might be caused by other clients accessing data. Please check if there is
any .ldb file in the same folder as the .mdb file. The .ldb file might be
hidden, and if there is, it means that others are accessing data on the
.mdb file. Please try to delete that file and run you application again.