This topic is locked

How many fields in the db?

9/29/2009 3:23:15 PM
ASPRunnerPro General questions
D
d_amboy author

I have a table called "Volunteers". I'd like to count the number of entries in this table and then display it on the page.
I've tried adding this code in ASPRunner in the "Events - Add Page Before Display" section. Here is the code that I tried. This works outside of ASPRunner but it clearly doesn't work within ASPRunner. Please let me know what you recommend. Thank you.
[indent]''Goal: Get the Count of Volunteers from the db

''Define the RecordSet, then specify a SQL query and open it

Dim varVolunteers

Dim RS_Count

Set RS_Count = Server.CreateObject("ADODB.Recordset")

RS_Count.Open "SELECT COUNT(FirstName) FROM Volunteers", objConn
''Close the db object at the end of its use

RS_Count.Close

Set RS_Count = Nothing
''Display the Count answer

Response.Write "Number of Volunteers: " & varVolunteers[/indent]

J
Jane 9/30/2009

Hi,
please see my changes below:

Dim varVolunteers

Dim RS_Count
Set RS_Count = Server.CreateObject("ADODB.Recordset")

RS_Count.Open "SELECT COUNT(FirstName) FROM Volunteers", dbConnection
varVolunteers = RS_Count(0)
RS_Count.Close

Set RS_Count = Nothing
Response.Write "Number of Volunteers: " & varVolunteers