当前位置:编程学习 > C#/ASP.NET >>

我有一段网站访问代码老是测试不成功,请高手给予指教

代码如下:
<%
Set Conn=Server.CreateObject("ADODB.Connection") 
Connstr="DBQ="+server.mappath("count.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" 
%> 

<%on error resume next%> 

<%
set server.createobject = ("adodb.recordset")
sql = "select * from count"
rs.open conn,1,3
if session("had")="" then
rs("hit") = rs("hit")+1
session("had")="no"
rs.update
end if
%>

<%set rs=conn.execute(sql)%> 

<% 
'更新每周每日数据 
lasthit=rs("lasthit") 
tdate=year(Now()) & "-" & month(Now()) & "-" & day(Now()) 
if trim(lasthit)=trim(tdate) then 
sql="update count set dayhit=dayhit+1 where id=1"
conn.Execute(sql) 
   'response.write "success" 
else 
sql="update count set dayhit=1 where id=1"
conn.Execute(sql) 
   'response.write "error" 
end if 
sql="update count set lasthit='"&tdate&"' where ID=1" 
conn.Execute(sql)

p_year=CInt(year(Now()))-CInt(year(lasthit)) 
p_month=CInt(month(Now()))-CInt(month(lasthit)) 
p_day=CInt(day(Now()))-CInt(day(lasthit)) 
period_time=((p_year*12+p_month)*30+p_day) 
if cint(period_time)=<cint(7) then 
sql="update count set weekhit=weekhit+1 where id=1" 
conn.Execute(sql) 
else 
sql="update count set weekhit=1 where id=1" 
conn.Execute(sql) 
end if 
%> 
document.write('<tr><td width="100%">今日访问<%=rs("dayhit")%>次,本周访问<%=rs("weekhit")%>次,总访问<%=rs("hit")%>次</td></tr>'); 
<%rs.close 
conn.close
set rs=nothing
set conn=nothing%>

测试结果为:  统计次数:今日访问次,本周访问次,总访问次

补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,