Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Please help with record count...
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

QuestionMan
Starting Member

4 Posts

Posted - 01 June 2001 :  11:56:30  Show Profile
I have a product detail page with users comments. Part of the table looks like this:

ID ProdID
1 55
2 55
3 56
4 56
5 57
6 57

The 'ID' referrs to the ID number for each comment. The 'ProdID' referrs to what product the comments are for. So, the URL for each page looks like
http://www.mydomain.com/comments.asp='ProdID'with the actual ProdID number in the place of 'ProdID'.

How do I count the number of times (in VBScript please) that the ProdID that matches the URL parameter reappears in the table?

davemaxwell
Access 2000 Support Moderator

USA
3020 Posts

Posted - 01 June 2001 :  13:14:18  Show Profile  Visit davemaxwell's Homepage  Send davemaxwell an AOL message  Send davemaxwell an ICQ Message  Send davemaxwell a Yahoo! Message
I'm sorry, I don't know if I 100% understand you. You have a table with a collection of products and comments and you want to get a count for how many comments were made for a certain product? I'm assuming that if you have a link www.mydomain.com/comments.asp?product=55 that you would only see the comment for product 55?

If so, there are a couple of ways to approach this:
1) Do it in an SQL statement:

<%
strSQL = Select count(*) as recordcount from product_table where ProdID = " & request("Product")
set rs = my_Conn.Execute (strSql)
RecordCount = rs("RecordCount")
rs.close
rs = nothing
Response.Write "# records = " & RecordCount
%>

2) Use the SQL to select all the values you want, then use the recordcount property:

<%
strSQL = Select comment, name from product_table where ProdID = " & request("Product")
rs.open strSql, my_Conn, 3

if rs.eof or rs.bof then
' no records found....
recordcount = 0
else
RecordCount = rs.RecordCount
do until rs.eof
:
: do other work here....
:
rs.movenext
loop
end if
rs.close
rs = nothing
Response.Write "# records = " & RecordCount
%>

3) Use the SQL to select all the values you want, then count the record manually:

<%
strSQL = Select comment, name from product_table where ProdID = " & request("Product")
rs.open strSql, my_Conn, 3

recordcount = 0
if rs.eof or rs.bof then
' no records, do nothing...
else
do until rs.eof
:
: do other work here....
:
RecordCount = RecordCount + 1
rs.movenext
loop
end if
rs.close
rs = nothing
Response.Write "# records = " & RecordCount
%>



Dave Maxwell
--------------
Proud to be a "World Class" Knucklehead
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.26 seconds. Powered By: Snitz Forums 2000 Version 3.4.07