Questo code fa funzionare un contatore di visite:
codice:
<%
Dim CounterFile

CounterFile = "counter.mdb"

Dim CookieSwitch

CookieSwitch = "on"

Dim CounterDataConn
Dim CounterSQL
Dim CounterRs
Dim CounterHits

Id = Clng(CounterId)

Set CounterDataConn = Server.CreateObject("ADODB.Connection")
CounterDataConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath(CounterFile)
CounterSQL = "SELECT * FROM Counter WHERE Id=" & Id
Set CounterRs = CounterDataConn.Execute(CounterSQL)
If CounterRs.EOF then
 CounterSQL = "INSERT INTO Counter(Id,Count) Values(" & Id & ",1)"
 Set CounterRs = CounterDataConn.Execute(CounterSQL)
 CounterHits = 1
Else
 If CounterAction = "GetStatus" then
  CounterHits = Clng(CounterRs("Count"))
 Else
  If NOT Request.Cookies("CounterHits") = "" and Id = 1 then
   CounterHits = Request.Cookies("CounterHits")
  Else
   CounterHits = Clng(CounterRs("Count"))
   CounterHits = CounterHits + 1
   CounterSQL = "UPDATE counter SET count = " & CounterHits & " where id = " & id
   CounterRs = CounterDataConn.Execute(CounterSQl)
   Response.Cookies("CounterHits") = CounterHits
  End If
 End If
End If

Set CounterRs = nothing
CounterDataConn.Close
Set CounterDataConn = nothing%>
tutto funziona meno che quando apro il dbase trovo l'id sempre a zero, deve funzionare così o l'id si deve incrementare per ogni visita? nella tbl id è previsto come numerico... :master: