求助ASP统计在线会员代码

来源:百度知道 编辑:UC知道 时间:2024/05/24 02:46:02
<%
lid=session("id")
lname=session("name")
u_sex=session("xingbie")
%>
<table align="center" width="700" height="20" border="0" cellspacing="0" cellpadding="0" class="intbl"><tr>
<td width="100%" height="100%" class="rdk2" style="padding:6px;">
<%
'在线成员表
IF lname<>"" THEN
'先删除超时了的在线成员
sqlstr="DELETE FROM tblonline WHERE o_laston<#"&dateadd("n",-20,now())&"#"
conn.Execute sqlstr
'检查该用户在线情况
sqlstr="SELECT o_laston FROM tblonline WHERE o_name='"&lname&"'"
rs.open sqlstr,conn,1,3
if rs.eof AND rs.bof then
rs.close
sqlstr="INSERT INTO tblonline(o_ID,o_name,o_sex,o_laston) VALUES("&lid&",'"&lname&"',&q

'列出在线成员表
dim o_icn
sqlstr="SELECT o_ID,o_name,o_sex FROM tblonline"
rs.open sqlstr,conn,1,1
dim mbolcnt
mbolcnt=rs.RecordCount

改为:
sqlstr="SELECT count(*) as online_num FROM tblonline"
set rs=conn.execute(sqlstr)
mbolcnt=Cint(rs("online_num"))
sqlstr="SELECT * FROM tblonline"
set rs=conn.execute(sqlstr)

'==============sql语句还可以精简.我不是很懂.