Print Page | Close Window

Incorrect Increment.

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=13396
Printed Date: 30 March 2026 at 7:46pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Incorrect Increment.
Posted By: neotrix
Subject: Incorrect Increment.
Date Posted: 18 January 2005 at 1:52am

here is a code i used to open a page from db and display it. How ever when I want to increment the field "PageCounter" by 1, it makes an increment of 6 Confused

 

<%

dim pageid

pageid=request("ost")

if pageid="" then pageid="2"

dim adocon

dim rspage

dim strsql

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("everything.mdb")

Set rspage = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT Pages.* FROM Pages WHERE PageID=" & pageid & ";"

rspage.Open strSQL, adoCon

dim pagehtml

pagehtml=rspage("PageHTML")

dim pagecounter

pagecounter=rspage("PageCounter")

pagehtml=replace(pagehtml,"[counter]",pagecounter)

response.write pagehtml

rspage.close

 

rspage.CursorType = 2

rspage.LockType = 3

rspage.Open strSQL, adoCon

rspage.Fields("PageCounter") = PageCounter+1

rspage.Update

rspage.Close

Set rsGuestbook = Nothing

Set adoCon = Nothing

%>

but as soon as I refresh the page, I see an increment of 6, rather than 1.


-------------
http://www.muhammadbinyusrat.com/blog/" rel="nofollow - Say to the believing men..



Replies:
Posted By: neotrix
Date Posted: 19 January 2005 at 1:45am
Ok, I think last time my font was small Confused Please help me out, I'm really clueless here.
 
==============================================
 
<%

dim pageid


pageid=request("ost")


if pageid="" then pageid="2"


dim adocon


dim rspage


dim strsql


Set adoCon = Server.CreateObject("ADODB.Connection")


adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("everything.mdb")


Set rspage = Server.CreateObject("ADODB.Recordset")


strSQL = "SELECT Pages.* FROM Pages WHERE PageID=" & pageid & ";"


rspage.Open strSQL, adoCon


dim pagehtml


pagehtml=rspage("PageHTML")


dim pagecounter


pagecounter=rspage("PageCounter")


pagehtml=replace(pagehtml,"[counter]",pagecounter)


response.write pagehtml


rspage.close


 


rspage.CursorType = 2


rspage.LockType = 3


rspage.Open strSQL, adoCon


rspage.Fields("PageCounter") = PageCounter+1 'This results in addition of 6, instead of 1.


rspage.Update


rspage.Close


Set rsGuestbook = Nothing


Set adoCon = Nothing


%>

 
This adds 6


-------------
http://www.muhammadbinyusrat.com/blog/" rel="nofollow - Say to the believing men..


Posted By: neotrix
Date Posted: 19 January 2005 at 6:08am
Can anybody help me please CryCryCryCryCryCryCryCryCryCryCryCryCryCry

-------------
http://www.muhammadbinyusrat.com/blog/" rel="nofollow - Say to the believing men..


Posted By: dj air
Date Posted: 19 January 2005 at 6:25am
replace pagecounter=rspage("PageCounter") with pagecounter= CLng(rspage("PageCounter"))

then see what that does, it should be one anyway. what value is the field to start with, is it 5 thaen it would show 6 (state the obvious but still ).

-----edit----
is the field within the database a number field.


Posted By: neotrix
Date Posted: 19 January 2005 at 11:19am
Yea it is a number field. Basically it was a logical fault.
The problem is, that I was using the same file (default.asp) to display 5 images in the same page. Now when it showed those 5 images, it increased the counter to 5, and when I added one more in it, It made 6. Which was, I thought, a problem with my IIS Big smile
 
Any ways thankyou very much Smile


-------------
http://www.muhammadbinyusrat.com/blog/" rel="nofollow - Say to the believing men..



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