Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating ADODB recordset but NOT database 2

Status
Not open for further replies.

sagn

Programmer
Jun 7, 2001
166
US
I have been trying to reset values in my recordset using syntax such as

rs.fields("colname").value = "value"

this seems to be fine.
But when I then try to do a MoveNext (or Move Previous)
I get a complaint that a column does not exist.
(This column is not necessarily the column I tried to update)

I don't want to update the database yet, only the recordset. Why might this be happening?

Thanks

sagn
 
What you should do in this case is read the results from your SQL query into an array, instead of a recordset. Now you can update as you wish without it affecting the database or causing problems as described above.

Take Care,
Mike
 
before the .movenext call the .cancelupdate method.

zemp
 
Or use a disconnected recordset
Code:
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open SQL, CN, adOpenKeyset, adLockBatchOptimistic
set rs.ActiveConnection = Nothing

[COLOR=black cyan]' Commands to Edit, etc.[/color black cyan]
 
Whenever you move between records in a recordset, update() is automatically called unless the lock type is adLockBatchOptimistic
 
Thanks a lot, one and all. I figured as much...

I'll try the rs.activeconnection=nothing call to see if that works...
as I'd rather not use the array method...

Thanks again. If I have any more questions about this
I'll be sure to ask!
 
<Whenever you move between records in a recordset, update() is automatically called unless the lock type is adLockBatchOptimistic

Not quite precisely true: this is of course only true of updatable recordsets. The default cursortype (firehose, or static on a client side recordset) is not updatable, which is why I'm making a point of this.

Golom's updatable recordsets are currently considered best practice in most cases. One thing, though: this is NOT a keyset recordset. All client-side cursors are static and not updatable. (adLockBatchOptimistic ones are batch updatable.) So, the adOpenKeyset directive in rs.Open is ignored.

Personally, I prefer to use client side recordsets, and do updates with command objects and SQL Server statements.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top