統(tǒng)計在線人數(shù) dxy
<%
sessid=session.sessionid
timeout=5 '分鐘
dim conn,connstr,dbpath
dbpath="online.mdb"
'connstr="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(dbpath)
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath(dbpath)
set conn=server.createobject("adodb.connection")
conn.open connstr
'刪除過期的session
aa=dateadd("n",-timeout,now())
response.write sessid&"<br />"
response.write aa
sqld="delete * from counts where postdate<#"&aa&"#"
conn.execute(sqld)
'保存id
sqlc="select sessid from counts where sessid='"&sessid&"'"
set rscheck=conn.execute(sqlc)
if rscheck.eof then
sqla="insert into counts(sessid,postdate)values('"&sessid&"','"&now()&"')"
conn.execute(sqla)
end if
rscheck.close
set rscheck=nothing
'計算人數(shù)
sqlall="select count(sessid) from counts"
set rs=conn.execute(sqlall)
countsall=rs(0)
rs.close
set rs=nothing
sql="select * from counts"
set rspredel=conn.execute(sql)
do until rspredel.eof
xxx=datediff("n",rspredel("postdate"),now())
if xxx>timeout then
countsall=countsall-1
end if
rspredel.movenext
loop
rspredel.close
set rspredel=nothing
conn.close
set conn=nothing
if countsall=0 then
countsall=1
end if
%>
當前有<%=countsall%>人
相關(guān)文章
九種防MDB數(shù)據(jù)庫被下載的方法小結(jié)
原來改mdb為asp就能防下載是鬼話。用Flashget試驗下載data.asp文件,并另存為data.mdb文件,發(fā)現(xiàn)用ACCESS打開完好無損!2006-06-06
javascript asp教程第三課 new String() 構(gòu)造器
javascript asp教程第三課 new String() 構(gòu)造器...2007-03-03
ASP編程中連接數(shù)據(jù)庫和數(shù)據(jù)庫操作的常用代碼
ASP編程中連接數(shù)據(jù)庫和數(shù)據(jù)庫操作的常用代碼...2007-11-11

