Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 22nd, 2005, 12:19 PM
Authorized User
 
Join Date: Jan 2004
Location: Blair, , United Kingdom.
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)
%>

Reply With Quote
  #2 (permalink)  
Old April 23rd, 2005, 04:19 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
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
Reply With Quote
  #3 (permalink)  
Old April 23rd, 2005, 07:09 PM
Authorized User
 
Join Date: Jan 2004
Location: Blair, , United Kingdom.
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
Reply With Quote
  #4 (permalink)  
Old April 26th, 2005, 07:03 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
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
Reply With Quote
  #5 (permalink)  
Old April 29th, 2005, 06:59 AM
Authorized User
 
Join Date: Jul 2004
Location: Hyderabad, Andhra Pradesh, India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:54 PM.


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