Jump to content

Increasing by 1..


denny911

Recommended Posts

Hello,In the table "mytbl" there's a field named "hits". I'm trying to make this piece of code below increase the value of that field by one.

<% Set conn = Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("database-path.mdb"))SQL = "UPDATE mytbl SET "sql=sql & " VALUES "sql=sql & "hits ='" & hits+1 & "'"sql=sql & " WHERE ID = " & ID & ""on error resume nextconn.Execute sql, recaffectedif err<>0 then Response.Write("Error!")else  Response.Write("Record Added")end if%>

Below this is the code that shows the value of the field hits and it works just fine. The problem is after I refresh the page, that value is NOT increased by 1, as it is supposed to be (the ERROR message appears but database's value is displayed). It only shows the value as it is, every time I refresh the page.Any suggestions?Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...