The following describes the implementation of simple counters with a database
' Save As Count.asp ' below
<%
Set conn=server.createobject ("ADODB. Connection ")
Conn. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & Server.MapPath ("Count.mdb")
%>
<%on Error Resume next%>
<%sql= "Update count set Hit=hit+1%><%conn. Execute (SQL)%>
<%sql = "SELECT * from Count"
Set Rs=conn.execute (SQL)
%>
<%
' Update weekly daily data
Lasthit=rs ("Lasthit")
Tdate=year (now ()) & '-' & Month (now ()) & '-' & Day (now ())
If Trim (lasthit) =trim (tdate) Then
Sql= "Update site set dayhit=dayhit+1 where id=" &request ("id")
Conn. Execute (SQL)
' Response.Write ' Success "
Else
Sql= "Update site set dayhit=1 where id=" &request ("id")
Conn. Execute (SQL)
' Response.Write ' ERROR "
End If
Sql= "Update site set lasthit= '" &tdate& "' Where id=" &request ("ID")
Conn. Execute (SQL)
P_year=cint (now ())-cint (year (lasthit))
P_month=cint (Month (now ()))-cint (month (lasthit))
P_day=cint (Today ())-cint (Day (Lasthit))
Period_time= ((p_year*12+p_month) *30+p_day)
If CInt (period_time) =
Sql= "Update site set weekhit=weekhit+1 where id=" &request ("id")
Conn. Execute (SQL)
Else
Sql= "Update site set weekhit=1 where id=" &request ("id")
Conn. Execute (SQL)
End If
%>
document.write (' Today visit <%=rs ("Dayhit")%> times, this week visit <%=rs ("Weekhit")%> times, Total Access <%=rs ("hit")%> times tr> ');
<%rs.close
Set rs=nothing%>
' Use
Build a database: Build a Count MDB library, build a table count, and the table field
Hit Digital type
Dayhit Digital Type
Weekhit Digital Type
Lasthit Date Type
Read this article believe you on the "How to build ASP counter" must have some understanding, if there is not understand can click Shanghai Treatment Impotence Hospital procedures to give you doubts oh?
ASP network programming: How to easily build an ASP counter