Jag vill räkna antalet unika unika ip-nummer i min databas, men jag får det inte att fungera.Räkna unika poster mot Access Xp
Jag får inget felmeddelande utan jag får inte in nått värde i variabeln överhuvudet taget.
<code><%@ Language=VBScript%>
<%
Option Explicit
'# constants & variables
Const adOpenStatic = 3
Const adLockOptimistic = 3
Dim objConn, objRs, strSql
Dim intUnik
'# open database
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("statsdb.mdb")
'# create recorset
Set objRs = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT COUNT(*) as intUnik FROM (SELECT DISTINCT Ip FROM hits) Hits"
objRs.Open strSql, objConn, adOpenStatic, adLockOptimistic
'# xhtml(strict) output
Response.Write "" &_
"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN""" &_
" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">" &_
"<html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""sv"" lang=""sv"">" &_
"<head><title>// WebStats //</title>" &_
"<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" />" &_
"<link rel=""STYLESHEET"" type=""text/css"" href=""../includes/stil.css"" />" &_
"</head><body>"
Response.Write intUnik & " unika besökare."
Response.Write "</table></body></html>"
'# closse database & recordset
objRs.Close: Set objRs = nothing
objConn.Close: Set objConn = nothing
%></code>