Print Page | Close Window

SQL Help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5663
Printed Date: 30 March 2026 at 9:39pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: SQL Help
Posted By: Gullanian
Subject: SQL Help
Date Posted: 10 September 2003 at 7:19pm

Ok guys, if anyone can tell me why this code is adding two to each counter, thanks it has solved a nice little problem.


statCurrYear = year(now())
statCurrMonth = month(now())
statCurrDay = day(now())
statCurrHour = hour(now())

'Do statistics
strSQL = "SELECT * from tblStats WHERE statYear = " & statCurrYear & " AND statMonth = " & statCurrMonth & " AND statDay = " & statCurrDay & " AND statHour = " & statCurrHour
rsCommon.open strSQL, adoCon

'Create if none exist
If rsCommon.eof or rsCommon.bof then
 
rsCommon.close
 
strSQL = "INSERT INTO tblStats (statYear,statMonth,StatDay,StatHour,sessions,pageViews) VALUES (" & statCurrYear & "," & statCurrMonth & "," & statCurrDay & "," & statCurrHour & ",0,0)"
 
rsCommon.open strSQL, adoCon
else
 
rsCommon.close
end if

'CURRENT HOUR SESSIONS/PAGE VIEWS
strSQL = "UPDATE tblStats SET pageViews = pageViews+1 "

If isEmpty(Session("blnCounterSet")) = True Then
 
strSQL = strSQL + (", sessions = sessions +1 ")
end if

strSQL = strSQL + (" WHERE statYear = " & statCurrYear & " AND statMonth = " & statCurrMonth & " AND statDay = " & statCurrDay & " AND statHour = " & statCurrHour)

rsCommon.open strSQL, adoCon

'TOTAL SESSIONS COUNT
If isEmpty(Session("blnCounterSet")) = True Then
 
strSQL = "UPDATE tblConfiguration SET sessions = " & lngSessions + 1
 
rscommon.open strSQL, adoCon
 
Session("blnCounterSet") = True
End if

'TOTAL PAGE VIEWS COUNT
strSQL = "UPDATE tblConfiguration SET pageviews = " & lngPageViews + 1
rscommon.open strSQL, adoCon

PS:  I took the code out and uploaded it, and it didnt update counters at all (prooves that this is the only code running on the counters)




Replies:
Posted By: Gullanian
Date Posted: 11 September 2003 at 8:05am
anyone?


Posted By: WebWiz-Bruce
Date Posted: 11 September 2003 at 8:07am
Have you tried initilising the variables before using them?

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net