Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Respone.Writing a count query

Status
Not open for further replies.

Garabaldi

Technical User
Jan 16, 2002
61
CA
Hi,

I'm trying to get a total for the amount of records I have in a table to write to an asp page.

Here is an example of my script so far:

Public objSystem
Public sSystem2
set objSystem = Server.CreateObject("ADODB.Recordset")

sSystem2 = "Select Count(*) From tb_System"
objSystem.Open sSystem2, objADOConn

How do I get the result of my Query to print to asp.

Thanks!!!
 
Try This,
Code:
myconn="Put your database connection string in here"
set rs = server.CreateObject("ADODB.Recordset")
getcountsql = "select count(*) from tb_System"
rs.Open getcountsql, myconn,1,2
if not rs.eof and not rs.bof then
    Response.Write("Total Record Count " & rs(0)
else
    Response.Write("No recordset created - ?")
end if
Regards,
S.
 
Oops there was a syntax erro in the last posting (sorry!) this is try this instead;

myconn="Put your database connection string in here"
set rs = server.CreateObject("ADODB.Recordset")
getcountsql = "select count(*) from tb_System"
rs.Open getcountsql, myconn,1,2
if not rs.eof and not rs.bof then
Response.Write("Total Record Count " & rs(0))
else
Response.Write("No recordset created - ?")
end if

Regards,
S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top