|
|
| YOUR HIT COUNTER IN ASP |
|
I will in this tutorial show you how to make a hit counter, using a
Accsess database.
|
Making the Hit-counter
|
|
When a user enters your site, you have to update the table in your database. I have called
my table for tbHits and the database for dbHits. The table has a column that register viewers
called: viewers.If you are not familiar to the connect
functions or the SQL statements, this tutotrial will show you the basics.
|
//connecting to the db
Dim objConn, viewers
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=" & Server.Mappath("dbHits.mdb") & ";"
strSQL = "SELECT * FROM tbHits"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn,2,2
viewers = objRS.fields("viewers") + 1
strSQL = "UPDATE tbHits SET viewers = '"& viewers &"' "
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn,2,2
Response.Write(viewers)
|
Download Source for the counter and db.
|
Category
|
Programming with ASP
|
|
Author
|
Tommy Johannessen
|
|
|
|