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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Recordset problem

Status
Not open for further replies.

Juppo

Technical User
Jun 13, 2003
15
GB
Hi
Im trying to make a user online counter (to count everyone viewing the site). Im a new to sql so obviously having trouble with things. In the internet database Im using a tabel called PPLONLINE with a field again called PPLONLINE. All I seem to be getting is -1 for a value even though there is alot. Can someone help me out?


Code:
<%
	DataSource = &quot;Driver={Microsoft Access Driver (*.mdb)}; 
        DBQ=&quot; & site_root & &quot;interdata/internet.mdb&quot; & &quot;;&quot;
	Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
        sql = &quot;select COUNT(PPLONLINE) from PPLONLINE&quot;
	rs.Open sql, DataSource 
		
NumberOfPplOnline = rs.RecordCount
	
	rs.Close
	Set rs= nothing
%>

 
Cheers that works great, but why?
Are you saying count rs from (0)? start at record 0 ?
 
Your query will only return one record with one result column. You can index the rs collection to get individual fields starting at 0.

rs.recordcount contains the number of records in the recordset. -1 means that the number of records is unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top