Re: Row cannot be located for updating

From: Val Mazur (group51a_at_hotmail.com)
Date: 04/24/04


Date: Fri, 23 Apr 2004 22:41:37 -0400

Hi,

Could be your case

http://support.microsoft.com/default.aspx?scid=kb;en-us;193515&Product=ado

-- 
Val Mazur
Microsoft MVP
"Veerle" <veerleverbr@hotmail.com> wrote in message 
news:16c55915.0404230548.676f4052@posting.google.com...
> Hi,
>
> I'm using ADO disconnected recordsets in my VB6 program. I use OLEDb
> to connect to a SQL Server 2000 DB.
>
> There I have a table Test with a primary key ID and no other indexes.
> I connect to de database, do "select * from Test where ID = 1" with as
> result a recordset containing one row, and disconnect the recordset.
> Then I change some field (other than ID), reconnect to the DB and
> execute an update. This gives me the error: "Row cannot be located for
> updating. Some values may have been changed since it was last read".
> Strangly enough, the value that I changed, is changed in the database
> as well...
>
> Any ideas what I'm doing wrong? Here's my code for the select:
>
>    'Open connection to the database
>    Dim Con As New ADODB.Connection
>    Con.Open ConnectionString
>    Con.CursorLocation = adUseClient
>
>    'Execute the query and remove the active connection
>    Dim Rs As New ADODB.Recordset
>    Rs.CursorLocation = adUseClient
>    Rs.Open Query, Con, adOpenForwardOnly, adLockBatchOptimistic
>    Set Rs.ActiveConnection = Nothing
>
>    'Close connection to the database
>    Con.Close
>    Set Con = Nothing
>
> And the code for the update:
>
>    'Open connection to the database
>    Dim Con As New ADODB.Connection
>    Con.Open ConnectionString
>    Con.CursorLocation = adUseClient
>
>    'Reconnect to the database and perform the update
>    Rs.ActiveConnection = Con
>    Rs.UpdateBatch
>
>    Rs.Close
>    Con.Close
>    Set Rs = Nothing
>    Set Con = Nothing 


Relevant Pages

  • Re: Connection types and speeds
    ... The memory used by holding the connection open is not ... All recordset inserts seen to consequently have 0ms execution time, ... actually written to the database while the code has regained control ... RecordsetClone of a form) when a transaction was rolled back, ...
    (microsoft.public.access.queries)
  • Re: VBA - "Out of stack space" error
    ... written for AutoCAD VBA generates an 'Out of stack space' ... I create the ADODB connection... ... > ' If the connection to the database has been opened ... where I try to open the recordset. ...
    (microsoft.public.vb.database.ado)
  • Re: adodb
    ... without knowing how the database is implemented. ... required to access a database when using ADO, although one can use ADO to ... A Connection object represents a unique session with a data source. ... A Recordset object represents the entire set of records from a base table ...
    (microsoft.public.vb.database.ado)
  • Re: adodb
    ... > without knowing how the database is implemented. ... > required to access a database when using ADO, although one can use ADO to ... > A Connection object represents a unique session with a data source. ... At any time, the Recordset object ...
    (microsoft.public.vb.database.ado)
  • Re: strange slowness with getrows method
    ... how many fields in the recordset? ... Can you try using the native OLEDB provider for your database rather than ... I notice that you are using the bad practice of supplying a connection ... > table to use the more efficient getrows method. ...
    (microsoft.public.inetserver.asp.db)