Counting RecordSets....

This is a discussion on "Counting RecordSets...." within the Classic ASP section. This forum, and the thread "Counting RecordSets.... are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Closed Thread
 
LinkBack Thread Tools
  #1  
Old Aug 27th, 2004, 20:02
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Counting RecordSets....

How do I go about doing this? Rob told me to do that but I couldn't figure it out. Is it objRS.Count or what? Also, been searching google and all I could really find on it is stuff about how the count messes up unless you count backwards... but not really any code for it. Any help would be much appreciated.

I'm trying to count objRS("ID") so that I can see on my details.asp page if the page exists or not. If the number is greater than the count then I give an "I'm sorry, this page does not exist". THanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Aug 27th, 2004, 21:14
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,188
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
are you referring to the recordcount property of the recordset object?

A simple objRS.RecordCount will return the number of records you have pulled with your SQL Select statement. If this returns zero, then you have no records. If it is not zero, then it holds a number equal to the number of records in the recordset (as the name suggests)

Was this what you meant?
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Aug 28th, 2004, 03:47
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, I'm having this problem. When I do as you stated above I get -1 . How can there be a -1 ? Any help/suggestions would be much appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Aug 28th, 2004, 08:31
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,188
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
Hi Court Jester....

You have to be using a cursor that will support this. adOpenStatic and adLockOptimistic are both cursor's that will return a recordcount. The cursor is specified when you call 'open'.

Does this make sense? If not, then please post your code.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old Aug 28th, 2004, 22:18
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Here's my code... everytime I put a cursor type in I get an error... This is the base coding, how would I set the cursor types? (sorry, I'm not used to this style of coding.

Code: Select all
<%
dim objRS
dim objConn
dim x

objRS = recordSet
objConn = connectionToDatabase
x = request.querystring("ID")


Set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionTimeout=60
objConn.Open "DSN=Mydatabase"

Set objRS = objConn.Execute("SELECT * FROM Page WHERE ID =" &x)
Response.Write(objRS.recordCount)

Response.Write(objRS("Content"))


objConn.close
Set objConn=Nothing

%>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
Old Aug 29th, 2004, 08:44
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,188
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
use this as your code to open the recordset:-
Code: Select all
RS.Open "SQL Query Here", ConnectionObject, adOpenKeySet,adLockOptimistic
You will need to reference the adovbs.inc (ADO CONSTANTS) file to enable you to use the constants (eg. adOpenKeySet) by name, instead of meaningless numbers.

Better still, place this in a file called global.asa in your root dir:-
Code: Select all
<!-- METADATA NAME="Microsoft ActiveX Data Objects 2.6 Library" 
     TYPE="TypeLib" UUID="{00000206-0000-0010-8000-00AA006D2EA4} -->
The aboive includes a reference to the CDO Constants in the .dll directly and allows access to the constants on every ASP page in your site. I referenced version 2.6, because I'm sure you'll have at least that version... search google if you want the right code for a higher version.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
counting, recordsets

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[need help-SEO]Counting no. of backlinks RohanShenoy Search Engine Optimization (SEO) 6 Feb 25th, 2008 06:51
Counting Instances in a table. Pheonix Databases 6 Mar 18th, 2006 22:16
PHP XML Counting Elements Don Logan PHP Forum 1 Mar 18th, 2006 03:03


All times are GMT. The time now is 16:03.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42