让access数据库表中某项定时归零
让access数据库表中某项定时归零,我想让数据库一周做一次统计,请问代码如何写?可能没有表述清Musiclist表中有两项是hits和weekhits,我希望weekh...
让access数据库表中某项定时归零,我想让数据库一周做一次统计,请问代码如何写?
可能没有表述清
Musiclist表中有两项是hits和weekhits,我希望weekhits每周都自动全部都归零,重新统计每周点击次数,与其它无关,主要是weekhits自动归零实现 展开
可能没有表述清
Musiclist表中有两项是hits和weekhits,我希望weekhits每周都自动全部都归零,重新统计每周点击次数,与其它无关,主要是weekhits自动归零实现 展开
1个回答
展开全部
用程序代码才能实现
<!--#include file="conn.asp"-->
<%
dim userip,user,tt,oto,zzday,counter,counters
dim today,daynum,yesterday,top,stats,browser
dim file,fso,Myfile,str
tt=now()
user=request.QueryString("user")
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
set rs=server.createobject("adodb.recordset")
sql="select * from counter"
rs.open sql,conn,1,3
oto=rs("oto")
if oto<>date() then
zzday=date()-1
application.lock
conn.Execute"Update counter set today=0,browser=0,oto=date(),daynum=daynum+1,yesterday="&rs("today")&""
conn.Execute"Insert into zzday(zzday,stats,browser) values ('"&zzday&"',"&rs("today")&","&rs("browser")&")"
application.unlock
Set fso = CreateObject("Scripting.FileSystemObject")
file=server.mappath("ip\"&date()&".txt")
Set MyFile = fso.CreateTextFile(file, True)
set rs=server.createobject("adodb.recordset")
sql="select * from userandip order by id desc"
rs.open sql,conn,1,3
while not rs.eof
str=rs("ip")& " " & rs("tt")
MyFile.WriteLine(str)
rs.movenext
wend
MyFile.Close
set rs=server.createobject("adodb.recordset")
sql="delete from UserandIP"
rs.open sql,conn,1,3
rs.close
set rs=nothing
else
application.lock
conn.Execute"Update counter set browser=browser+1"
set rs=server.createobject("adodb.recordset")
sql="select * from UserandIP where IP='"&userip&"' order by ID desc"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.addnew
rs("IP")=userip
rs("User")=user
rs("tt")=tt
rs.update
conn.Execute"Update counter set counter=counter+1,today=today+1"
end if
rs.close
set rs=nothing
application.unlock
end if
set rs=server.createobject("adodb.recordset")
sql="select * from counter"
rs.open sql,conn,1,3
if rs("top")<rs("today") then
conn.Execute"Update counter set [top]="&rs("today")&""
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<!--#include file="conn.asp"-->
<%
dim userip,user,tt,oto,zzday,counter,counters
dim today,daynum,yesterday,top,stats,browser
dim file,fso,Myfile,str
tt=now()
user=request.QueryString("user")
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
set rs=server.createobject("adodb.recordset")
sql="select * from counter"
rs.open sql,conn,1,3
oto=rs("oto")
if oto<>date() then
zzday=date()-1
application.lock
conn.Execute"Update counter set today=0,browser=0,oto=date(),daynum=daynum+1,yesterday="&rs("today")&""
conn.Execute"Insert into zzday(zzday,stats,browser) values ('"&zzday&"',"&rs("today")&","&rs("browser")&")"
application.unlock
Set fso = CreateObject("Scripting.FileSystemObject")
file=server.mappath("ip\"&date()&".txt")
Set MyFile = fso.CreateTextFile(file, True)
set rs=server.createobject("adodb.recordset")
sql="select * from userandip order by id desc"
rs.open sql,conn,1,3
while not rs.eof
str=rs("ip")& " " & rs("tt")
MyFile.WriteLine(str)
rs.movenext
wend
MyFile.Close
set rs=server.createobject("adodb.recordset")
sql="delete from UserandIP"
rs.open sql,conn,1,3
rs.close
set rs=nothing
else
application.lock
conn.Execute"Update counter set browser=browser+1"
set rs=server.createobject("adodb.recordset")
sql="select * from UserandIP where IP='"&userip&"' order by ID desc"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.addnew
rs("IP")=userip
rs("User")=user
rs("tt")=tt
rs.update
conn.Execute"Update counter set counter=counter+1,today=today+1"
end if
rs.close
set rs=nothing
application.unlock
end if
set rs=server.createobject("adodb.recordset")
sql="select * from counter"
rs.open sql,conn,1,3
if rs("top")<rs("today") then
conn.Execute"Update counter set [top]="&rs("today")&""
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询