Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP 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 April 16th, 2009, 10:50 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recordset count

Hi,

How do you get how many records in a recordset...

Set rs = Server.CreateObject("ADODB.recordset")
rs.Open sql,db

I try the following, and it gives me -1, but I *know* that there are 4 records in the sql query that I'm testing...

response.write rs.RecordCount

Tried
rs.Count, and I get the following error...


Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'rs.Count' /dev/tab_test1.asp, line 12
 
Old April 16th, 2009, 07:10 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

When you just do
Code:
rs.Open sql, db
you get a FORWARD ONLY cursor, and you can't get the record count from such a cursor. You need to use a STATIC cursor, via adOpenStatic. Or, in practical terms:
Code:
rs.Open sql, db, 3 ' yes, 3 is adOpenStatic
response.write rs.RecordCount
 
Old May 28th, 2009, 02:54 AM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to J1NK5
Default

Or if you are cycling through the records anyway just add a manual count.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Count string occurences across recordset goldstein SQL Server 2005 1 July 9th, 2007 06:47 PM
Recordset Count starting from 1 till end nouky Classic ASP Databases 24 October 30th, 2006 06:22 PM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
SQL record count / recordset chacquard Access VBA 4 July 3rd, 2004 04:41 AM
Recordset count niravp Classic ASP Databases 6 October 26th, 2003 02:41 PM





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