Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 16th, 2009, 10:50 AM
Friend of Wrox
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recordset count


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

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
Reply With Quote
  #2 (permalink)  
Old April 16th, 2009, 07:10 PM
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

When you just do
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:
rs.Open sql, db, 3 ' yes, 3 is adOpenStatic
response.write rs.RecordCount
Reply With Quote
  #3 (permalink)  
Old May 28th, 2009, 02:54 AM
Registered User
Join Date: Dec 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to J1NK5

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 08:07 PM.

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