
ADO Error : The specified row could not be located for updating
Hi,
When I run this code in VB6, I have an error (see source code below) on
the second UpdateBatch line.
Can you tell me why? An how to solve this problem?
Thanks for your help,
Denis
------------
Source Code:
------------
Private Sub Command1_Click()
'1. Add References "Microsoft ActiveX Data Objects 2.0 Library"
'2. Copy Bilbio.mdb to "C:\Temp"
'3. Run this program
'4. Error Message = "The specified row could not be located for
updating:
' Some values may have been changed since it was last
read."
Dim mConnection As ADODB.Connection
Dim mRecordset As ADODB.Recordset
'Initialize
Set mConnection = New ADODB.Connection
Set mRecordset = New ADODB.Recordset
'Open
mConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security
Info=False;" & _
"Data Source=C:\Temp\Biblio.mdb"
mRecordset.CursorLocation = adUseClient
mRecordset.CursorType = adOpenDynamic
mRecordset.LockType = adLockBatchOptimistic
mRecordset.Open "Authors", mConnection, , , adCmdTable
'Addnew
mRecordset.AddNew
mRecordset("Author") = "Hello"
mRecordset.Update
mRecordset.UpdateBatch
'Update
mRecordset("Author") = "Hello Updated"
mRecordset.Update
mRecordset.UpdateBatch
'Terminate
Set mConnection = Nothing
Set mRecordset = Nothing
End Sub