Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 22nd, 2005, 12:19 PM
Authorized User
 
Join Date: Jan 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hit Counter Help!

Hi, Im a beginner with ASP and Im trying to use a very simple hit counter on my page, I can display the current value in the database no problem, but the code I have does not update the number each time the page loads. Im not quite sure whats going on can someone help, thanks!

Neil

<%
    Dim objConn, objRS
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set ObjRS = Server.CreateObject("ADODB.Recordset")

    objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
    strDBFile = Server.MapPath(".") & "\database.mdb"
    objConn.Open strDBFile
    Set objRS.ActiveConnection = objConn

    objRS.Open "SELECT wapcount from hitcounter"
    SQL = UPDATE hitcounter SET wapcounter = wapcounter + 1
    objConn.Execute(SQL)
%>

 
Old April 23rd, 2005, 04:19 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please modify ur code as:

<%
    Dim objConn, objRS
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set ObjRS = Server.CreateObject("ADODB.Recordset")

    objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
    strDBFile = Server.MapPath(".") & "\database.mdb"
    objConn.Open strDBFile

    SQL = UPDATE hitcounter SET wapcounter = wapcounter + 1
    objConn.Execute(SQL)

    Set objRS.ActiveConnection = objConn
    objRS.Open "SELECT wapcount from hitcounter"
%>

Om Prakash
 
Old April 23rd, 2005, 07:09 PM
Authorized User
 
Join Date: Jan 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks Om but that doesnt work, its just a re-arranged version of my previous code so it does the same job and still doesnt work. I just have problems adding 1 to the current value in the database and updating that value so it saves. I cannot get it to work.

Help from someone would be appreciated.

Thanks

Neil
 
Old April 26th, 2005, 07:03 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

The code rearranged because, you are selecting the data from the sametable and then updating the table. I thought, the data is updated but it is not getting reflected.

Can u provide some more information..

What is the initial or current value of the wapcounter?
Do you get any error after update statement?

Om Prakash
 
Old April 29th, 2005, 06:59 AM
Authorized User
 
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to raj_makro
Default

Hi Neil
Please modify ur code as:

<%
    Dim objConn, objRS, SQL
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set ObjRS = Server.CreateObject("ADODB.Recordset")

    objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
    strDBFile = Server.MapPath(".") & "\database.mdb"
    objConn.Open strDBFile

    SQL = "UPDATE hitcounter SET wapcounter = 1 where wapcounter is null"
    objConn.Execute(SQL)

    SQL = "UPDATE hitcounter SET wapcounter = wapcounter + 1"
    objConn.Execute(SQL)

    Set objRS.ActiveConnection = objConn
    objRS.Open "SELECT wapcount from hitcounter"
%>

Regards
Raj

Regards
Raj





Similar Threads
Thread Thread Starter Forum Replies Last Post
A Hit Counter, PLEASE HELP !!!!! ARD_40 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 April 23rd, 2006 06:25 AM
hit counter gumgak Classic ASP Basics 2 November 2nd, 2003 12:44 AM
Hit Counter mateenmohd HTML Code Clinic 7 September 28th, 2003 07:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.