Hi, all:
I'm trying to update a column in a mysql table using myODBC and VBA and I'm getting the following error when I hit the 'update' statement: "Query-based update failed because the row to update could not be found."
Here's my code:
Dim Conn As ADODB.Connection
Dim rsPoles As ADODB.Recordset
Set Conn = CreateObject("ADODB.Connection")
Conn.Open "FILE NAME=C:\nelson\photos-mysql.udl", "<username>", "<password>"
Set rsPoles = CreateObject("ADODB.Recordset")
rsPoles.Open "SELECT * FROM photos WHERE id=4201", Conn, adOpenStatic, adLockOptimistic
rsPoles.MoveFirst
Dim sTemp, x As Variant
sTemp = rsPoles.Fields("photocaption").Value
x = rsPoles.Fields("id").Value
rsPoles.Close
rsPoles.Open "SELECT * FROM photos WHERE id=x", Conn, adOpenKeyset, adLockOptimistic
MsgBox sTemp
rsPoles!PhotoCaption = "Gollee Bob Howdy!"
'Update the recordset -- here's where it bombs!!!!
rsPoles.Update
rsPoles.Close
I've tried using all the adLock values and the adCursorTypes in the Open, but nothing seems to work.
Could someone help me with this?
Thanks!
Paul