473,406 Members | 2,769 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,406 software developers and data experts.

Update problem

When I try to update record, I kept getting this error:

Row cannot be located for updating. Some values may have been changed since
it was last read.

No other users are accessing the database - only 1 user is accessing the
database.

I open the data using adLockOptimistic locking.

I am converting the app. from Access/MSSQL databases to MySQL and the same
code works for both accept MySQL.

Any help greatly appreciated.

Tks
John
Feb 6 '06 #1
9 3187
More information on this problem.

This only happens on 3 records out of 30. I've tried repairing the database
and still same problem.

Tks
John
"zMisc" <yo********@hotmail.com> wrote in message
news:11********************@news-server.bigpond.net.au...
When I try to update record, I kept getting this error:

Row cannot be located for updating. Some values may have been changed
since it was last read.

No other users are accessing the database - only 1 user is accessing the
database.

I open the data using adLockOptimistic locking.

I am converting the app. from Access/MSSQL databases to MySQL and the same
code works for both accept MySQL.

Any help greatly appreciated.

Tks
John

Feb 7 '06 #2
"zMisc" <yo********@hotmail.com> wrote in message
news:11********************@news-server.bigpond.net.au...
When I try to update record, I kept getting this error:

Row cannot be located for updating. Some values may have been changed
since it was last read.


Here's a topic in the MySQL docs that addresses this issue:
http://dev.mysql.com/doc/refman/5.0/...-conflict.html

You need to enable the "Return Matching Rows" option in MyODBC. This is
required to use MS Access. I can't tell you what that is for.

The solution is also mentioned on this page about making MySQL & MyODBC work
with MS Access:
http://dev.mysql.com/doc/refman/5.0/...th-myodbc.html

Here's another reference, more complete with screen shots of the proper way
to set up the MyODBC DSN for MS Access:
http://sparxsystems.com.au/EAUserGui...odbcdriver.htm

Regards,
Bill K.
Feb 7 '06 #3
Hi Bill,

Once again thanks for your reply.

I've tried below and none works - I am using MyODBC to access MySQL not MS
Access. The error is happening on a MySQL table.

I tried change OPTION=2 as suggested in
http://dev.mysql.com/doc/refman/5.0/...-conflict.html and still get the
same error.

Do you know where I can find the documentation for all the options for
connection string?

Tks
John
"Bill Karwin" <bi**@karwin.com> wrote in message
news:ds*********@enews2.newsguy.com...
"zMisc" <yo********@hotmail.com> wrote in message
news:11********************@news-server.bigpond.net.au...
When I try to update record, I kept getting this error:

Row cannot be located for updating. Some values may have been changed
since it was last read.


Here's a topic in the MySQL docs that addresses this issue:
http://dev.mysql.com/doc/refman/5.0/...-conflict.html

You need to enable the "Return Matching Rows" option in MyODBC. This is
required to use MS Access. I can't tell you what that is for.

The solution is also mentioned on this page about making MySQL & MyODBC
work with MS Access:
http://dev.mysql.com/doc/refman/5.0/...th-myodbc.html

Here's another reference, more complete with screen shots of the proper
way to set up the MyODBC DSN for MS Access:
http://sparxsystems.com.au/EAUserGui...odbcdriver.htm

Regards,
Bill K.

Feb 7 '06 #4
"zMisc" <yo********@hotmail.com> wrote in message
news:r%***************@news-server.bigpond.net.au...
I've tried below and none works - I am using MyODBC to access MySQL not MS
Access. The error is happening on a MySQL table.
Woops! You mentioned MS Access, so I assumed you are still using Access as
a front-end to MySQL.
I tried change OPTION=2 as suggested in
http://dev.mysql.com/doc/refman/5.0/...-conflict.html and still get
the same error.
Here's a thread that suggests that using floating-point or datetime columns
is your primary key can make it unreliable for the ADO layer to locate the
record by its primary key.
http://www.dbforums.com/archive/index.php/t-333957.html

By the way, can you confirm that the query you are trying to update from is
updateable?
In other words, are you including the primary key field in the query, and
are not doing any aggregates (GROUP BY), or other types of queries that
would make it non-updateable?
Do you know where I can find the documentation for all the options for
connection string?


This page looks like it has a good reference for MyODBC connection options:
http://dev.mysql.com/doc/refman/5.0/...arameters.html

Regards,
Bill K.
Feb 8 '06 #5
Hi Bill,

The primary key is a Long integer.

There's no GROUP BY. It is definitely updateable as this happens on 2 out of
3 records only (of the same record) - this is the strange part.

The exact same codes works with MS Access and MS SQL databases.

Rgds
Young
"Bill Karwin" <bi**@karwin.com> wrote in message
news:ds*********@enews4.newsguy.com...
"zMisc" <yo********@hotmail.com> wrote in message
news:r%***************@news-server.bigpond.net.au...
I've tried below and none works - I am using MyODBC to access MySQL not
MS Access. The error is happening on a MySQL table.


Woops! You mentioned MS Access, so I assumed you are still using Access
as a front-end to MySQL.
I tried change OPTION=2 as suggested in
http://dev.mysql.com/doc/refman/5.0/...-conflict.html and still get
the same error.


Here's a thread that suggests that using floating-point or datetime
columns is your primary key can make it unreliable for the ADO layer to
locate the record by its primary key.
http://www.dbforums.com/archive/index.php/t-333957.html

By the way, can you confirm that the query you are trying to update from
is updateable?
In other words, are you including the primary key field in the query, and
are not doing any aggregates (GROUP BY), or other types of queries that
would make it non-updateable?
Do you know where I can find the documentation for all the options for
connection string?


This page looks like it has a good reference for MyODBC connection
options:
http://dev.mysql.com/doc/refman/5.0/...arameters.html

Regards,
Bill K.

Feb 8 '06 #6
Young,
I have exactly the same problem with "row cannot be located..." I've trid all
the fixex suggested in replies to your post but, like you, have not got the
problem to go away.

Have you been able to find a fix or work around?

Thanks in advance,

Giles
zMisc wrote:
Hi Bill,

The primary key is a Long integer.

There's no GROUP BY. It is definitely updateable as this happens on 2 out of
3 records only (of the same record) - this is the strange part.

The exact same codes works with MS Access and MS SQL databases.

Rgds
Young
I've tried below and none works - I am using MyODBC to access MySQL not
MS Access. The error is happening on a MySQL table.

[quoted text clipped - 26 lines]
Regards,
Bill K.

Feb 15 '06 #7
Giles,

I've not been able to fix it.

Please see http://bugs.mysql.com/bug.php?id=17213 (I've reported this to
MySQL). Have not tried the possible fix on rounding the floating number to 2
decimal places yet.

Are you updating a floating point number (mine is)?

Rgds
Young
"gpatters888" <u18732@uwe> wrote in message news:5be53ac1ffece@uwe...
Young,
I have exactly the same problem with "row cannot be located..." I've trid
all
the fixex suggested in replies to your post but, like you, have not got
the
problem to go away.

Have you been able to find a fix or work around?

Thanks in advance,

Giles
zMisc wrote:
Hi Bill,

The primary key is a Long integer.

There's no GROUP BY. It is definitely updateable as this happens on 2 out
of
3 records only (of the same record) - this is the strange part.

The exact same codes works with MS Access and MS SQL databases.

Rgds
Young
I've tried below and none works - I am using MyODBC to access MySQL not
MS Access. The error is happening on a MySQL table.

[quoted text clipped - 26 lines]
Regards,
Bill K.

Feb 15 '06 #8
Hi Young,
My problem occurs when I attempt the update after changing a datetime field
that was previously contained a null value. (Everything works if the previous
value is not null...)

However I've managed a work around....

The work around involves using objconn.Excecute with an SQL UPDATE string....
This works well for most cases however I do not know how to correctly deal
with " characters occurin in the middl of long text values (e.g. in the
middle of a memo field) so I ended up using both methods. When the first
method throws an error then the error processing uses the second method to
handle the exception before returning control back.

Effectively...
Dim and set the ADODB connection object objconn
Dim and set an ADODB recordset rst

On err goto Err_Handler
Set up the SQL update string
For each record that has changed...
For each fld that needs updating...
objconn.Execute strSQL
Continue:
Next fld
Next record
Exit:
Close and nothing everything
Exit Sub
Err_Handler:
If err is SQL syntax error then
rst(fldname).Value = new value
rst.Update
Resume at Continue
Else
Report error
Resume Exit
End if
End Sub
I've attached a code sample below....Please note the the SQL method seemed to
work well so I used that as the main method and only use the ADO update
method when an SQL syntax error is thrown (due to those " characters...).
However no reason it would not work the other way around...

A couple of points to note:
1. In this case the connection object is public and is created/set elsewhere.
2. The software deals one at a time with each field in each record that needs
to be updated. This makes it easy to switch to the other method although it's
probably not the best for performance.

Hope all this helps your situation....
Giles
Function UpdateContact(strAction As String, rsSugar As ADODB.Recordset,
objContact As Object, strID As String)
On Error GoTo Err_UpdateContact

Dim db As DAO.Database
Dim rsFields As DAO.Recordset ' rsFields contains the names of the
fields for synching
Dim qdf As DAO.QueryDef

Dim i As Boolean

Dim strTextS, strItemS As String
Dim strTextO, strItemO As String
Dim lngIndexO As Long
Dim old As String
Dim strSQLUpdate As String

Dim objItems As Outlook.ItemProperties
Dim objItem As Outlook.ItemProperty

Set db = CurrentDb
Set qdf = db.QueryDefs("qryFieldsForContacts")
Set rsFields = qdf.OpenRecordset

UpdateContact = False ' Assume it did not update...

Select Case strAction
Case "UpdateSugar"
rsFields.MoveFirst
Do Until rsFields.EOF
strItemS = rsFields!SugarFieldName
If strItemS <> "name" Then
strItemO = rsFields!OutlookFieldIndex
lngIndexO = Val(strItemO)
Set objItems = objContact.ItemProperties
Set objItem = objItems.Item(lngIndexO)
strTextO = objItem.Value
If strTextO <> "" And Not IsNull(strTextO) Then
If rsSugar(strItemS) <> strTextO Then
old = """" ' sets up the SQL text delimiter
character...
strSQLUpdate = "UPDATE contacts SET contacts." &
strItemS
strSQLUpdate = strSQLUpdate & " = " & old &
strTextO & old & " WHERE (("
strSQLUpdate = strSQLUpdate & "Contacts.id)=" &
old & strID & old & ")"

pubconnCRM.Execute strSQLUpdate, ,
adExecuteNoRecords
Next_UpdateContact:
End If
End If
End If
rsFields.MoveNext
Loop
UpdateContact = True
End Select

Exit_UpdateContact:
qdf.Close
rsFields.Close
db.Close
Set qdf = Nothing
Set rsFields = Nothing
Set db = Nothing
Exit Function

Err_UpdateContact:
If Err.Number = -2147217900 Then
' This is an SQL syntax error, most likely caused by a " character in
a field
' Try to correct using the ADO update method...

rsSugar(strItemS) = strTextO
rsSugar.Update
Resume Next_UpdateContact
Else
MsgBox Err.Description
UpdateContact = False
Resume Exit_UpdateContact
End If
End Function

zMisc wrote:
Giles,

I've not been able to fix it.

Please see http://bugs.mysql.com/bug.php?id=17213 (I've reported this to
MySQL). Have not tried the possible fix on rounding the floating number to 2
decimal places yet.

Are you updating a floating point number (mine is)?

Rgds
Young
Young,
I have exactly the same problem with "row cannot be located..." I've trid

[quoted text clipped - 27 lines]
Regards,
Bill K.


--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....neral/200602/1
Feb 16 '06 #9
Hi Giles,

Tks for the tip.

I will try it on mine.

Rgds
Young

"gpatters888 via DBMonster.com" <u18732@uwe> wrote in message
news:5bf55a6e5202c@uwe...
Hi Young,
My problem occurs when I attempt the update after changing a datetime
field
that was previously contained a null value. (Everything works if the
previous
value is not null...)

However I've managed a work around....

The work around involves using objconn.Excecute with an SQL UPDATE
string....
This works well for most cases however I do not know how to correctly deal
with " characters occurin in the middl of long text values (e.g. in the
middle of a memo field) so I ended up using both methods. When the first
method throws an error then the error processing uses the second method to
handle the exception before returning control back.

Effectively...
Dim and set the ADODB connection object objconn
Dim and set an ADODB recordset rst

On err goto Err_Handler
Set up the SQL update string
For each record that has changed...
For each fld that needs updating...
objconn.Execute strSQL
Continue:
Next fld
Next record
Exit:
Close and nothing everything
Exit Sub
Err_Handler:
If err is SQL syntax error then
rst(fldname).Value = new value
rst.Update
Resume at Continue
Else
Report error
Resume Exit
End if
End Sub
I've attached a code sample below....Please note the the SQL method seemed
to
work well so I used that as the main method and only use the ADO update
method when an SQL syntax error is thrown (due to those " characters...).
However no reason it would not work the other way around...

A couple of points to note:
1. In this case the connection object is public and is created/set
elsewhere.
2. The software deals one at a time with each field in each record that
needs
to be updated. This makes it easy to switch to the other method although
it's
probably not the best for performance.

Hope all this helps your situation....
Giles
Function UpdateContact(strAction As String, rsSugar As ADODB.Recordset,
objContact As Object, strID As String)
On Error GoTo Err_UpdateContact

Dim db As DAO.Database
Dim rsFields As DAO.Recordset ' rsFields contains the names of the
fields for synching
Dim qdf As DAO.QueryDef

Dim i As Boolean

Dim strTextS, strItemS As String
Dim strTextO, strItemO As String
Dim lngIndexO As Long
Dim old As String
Dim strSQLUpdate As String

Dim objItems As Outlook.ItemProperties
Dim objItem As Outlook.ItemProperty

Set db = CurrentDb
Set qdf = db.QueryDefs("qryFieldsForContacts")
Set rsFields = qdf.OpenRecordset

UpdateContact = False ' Assume it did not update...

Select Case strAction
Case "UpdateSugar"
rsFields.MoveFirst
Do Until rsFields.EOF
strItemS = rsFields!SugarFieldName
If strItemS <> "name" Then
strItemO = rsFields!OutlookFieldIndex
lngIndexO = Val(strItemO)
Set objItems = objContact.ItemProperties
Set objItem = objItems.Item(lngIndexO)
strTextO = objItem.Value
If strTextO <> "" And Not IsNull(strTextO) Then
If rsSugar(strItemS) <> strTextO Then
old = """" ' sets up the SQL text delimiter
character...
strSQLUpdate = "UPDATE contacts SET contacts."
&
strItemS
strSQLUpdate = strSQLUpdate & " = " & old &
strTextO & old & " WHERE (("
strSQLUpdate = strSQLUpdate & "Contacts.id)=" &
old & strID & old & ")"

pubconnCRM.Execute strSQLUpdate, ,
adExecuteNoRecords
Next_UpdateContact:
End If
End If
End If
rsFields.MoveNext
Loop
UpdateContact = True
End Select

Exit_UpdateContact:
qdf.Close
rsFields.Close
db.Close
Set qdf = Nothing
Set rsFields = Nothing
Set db = Nothing
Exit Function

Err_UpdateContact:
If Err.Number = -2147217900 Then
' This is an SQL syntax error, most likely caused by a " character
in
a field
' Try to correct using the ADO update method...

rsSugar(strItemS) = strTextO
rsSugar.Update
Resume Next_UpdateContact
Else
MsgBox Err.Description
UpdateContact = False
Resume Exit_UpdateContact
End If
End Function

zMisc wrote:
Giles,

I've not been able to fix it.

Please see http://bugs.mysql.com/bug.php?id=17213 (I've reported this to
MySQL). Have not tried the possible fix on rounding the floating number to
2
decimal places yet.

Are you updating a floating point number (mine is)?

Rgds
Young
Young,
I have exactly the same problem with "row cannot be located..." I've
trid

[quoted text clipped - 27 lines]
> Regards,
> Bill K.


--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....neral/200602/1

Feb 16 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Harald Servat Gelabert | last post by:
Dear news-team I'm using MySQL 4.0.15a (with PHP 4.3.4rc1 and Apache 2.0.47 under FreeBSD). I'm having problems when updating a column of a table (it updates an extra column). As an...
2
by: aaj | last post by:
Hi all I have a continuous bound form and on each record is a tick box. The user ticks the boxes and these boxes define the batch. for future operations before they leave the page I count...
3
by: Reney | last post by:
I haven't used the VS Studio's drag&drop method to create my connection, adapters and datasets, but I typed them all. The situation is like this: There is a listbox with members pulled from 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: Kevin Hodgson | last post by:
I'm experiencing a strange Dataset Update problem with my application. I have a dataset which has a table holding a set of customer information records. (address, contact, info, etc.) I have a...
4
by: Jeremy | last post by:
My app is throwing an exception regarding trying to post a null to a required field. Examining the datarow in question, I see a valid date value. The row's state is "added" I'm relying on an ...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
15
by: Scotty | last post by:
I like to have a good insert, update and delete code The code below sometimes workl ok sometimes doesnt work, what i am doing wrong?? Sub SaveAny() Dim command_builder As New...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.