Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2004, 08:00 AM
Registered User
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB/ADO: AddNew does NOT increment RecordCount

Hi all,

I am working with ADO/VB6 and (frequently) using disconnected client-side recordsets. On a couple of cases I encountred this strange behavior: I use AddNew to add a record field by field but RecordCount is still 0. This is the code to create the recordset:
**********BEGIN CODE
  If Not adoPrimaryCRS.State = adStateClosed Then adoPrimaryCRS.Close
  With adoPrimaryCRS
    'Specify the cursor’s location
    .CursorLocation = adUseClient
    .Open sqlPrimC, db1, adOpenStatic, adLockBatchOptimistic
  End With
**********END CODE
Adding a watch (debugger): The recordset RecordCount = 0 BUT AbsolutePosition = 1! Also, the fields contain the new data just fine.
Later, when I go thru the recordset looking for new records to insert into DB, that record does not show up and is not inserted.
Usually it works fine! I have to point out that I am calling the function that contains the above code from many places.

Thank you,
Mo
 
Old July 23rd, 2004, 12:38 PM
Authorized User
 
Join Date: Jul 2004
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't think it will since it is a "batch" transaction. You'll need to do the .BatchUpdate in there somewhere.

David
 
Old July 29th, 2004, 02:13 AM
Registered User
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks David. I believe that did the trick. However I'm surprised it only happened this one time. I got similar code that works just fine. I guess I could try reproducing it with a similar scenario.

Mo

 
Old August 2nd, 2004, 04:42 AM
Authorized User
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could also try
rs.movelast
rsmovefirst
This updates the recordcount.


Lucian Preda
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help RecordCount jpaul Pro VB Databases 1 January 29th, 2008 01:46 PM
RecordCount dpkbahuguna Beginning VB 6 9 March 23rd, 2006 01:16 AM
efficiency qn:ado .AddNew VS INSERT in stored proc ak Classic ASP Databases 1 February 25th, 2004 10:08 AM
effieciency: ado .AddNew vs Insert in Stored proc ak SQL Server ASP 2 February 25th, 2004 09:20 AM
.addnew for Ado.net? paulwalker ADO.NET 1 September 20th, 2003 10:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.