Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!
I have a page I created in Frontpage with a form posting to an access database. I want to count the number of records that are of a certain type. I've search the web and found some code examples, but can't get the information to display. No error messages, just no information.
My access database is published to the webserver under the standard fpdb directory. It's called Results.
Here is my ASP code

Database is index.mdb under the fpdb directory. Table is Results.

<%
'Dimension variables
Dim conn 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Dim rc
Dim myCount
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("index.mdb"))
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT COUNT(*) myCount FROM Results WHERE Category='Appetizer'"
rs.Open "Results", strSQL, conn
rc=rs("myCount")
rs.Close
conn.Close
Set rs=Nothing
Set conn=Nothing
%>

In HTML page here is the code I use to print out results.
<%response.write "App Total = " & rc%>

It writes App Total, just no value after the = sign.
Ugh!
Help anybody!
Posted
Updated 10-Feb-10 3:00am
v2

1 solution

Shouldn't it be "SELECT COUNT(*) AS myCount"?

It's so long since I've done old ASP that I do not remember, whether it should through an exception in that case or not.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900