Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Incorrect Increment.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Incorrect Increment.

 Post Reply Post Reply
Author
neotrix View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 09 November 2003
Location: Pakistan
Status: Offline
Points: 433
Post Options Post Options   Thanks (0) Thanks(0)   Quote neotrix Quote  Post ReplyReply Direct Link To This Post Topic: Incorrect Increment.
    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.


Edited by neotrix - 18 January 2005 at 1:54am
Back to Top
neotrix View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 09 November 2003
Location: Pakistan
Status: Offline
Points: 433
Post Options Post Options   Thanks (0) Thanks(0)   Quote neotrix Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
neotrix View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 09 November 2003
Location: Pakistan
Status: Offline
Points: 433
Post Options Post Options   Thanks (0) Thanks(0)   Quote neotrix Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2005 at 6:08am
Can anybody help me please CryCryCryCryCryCryCryCryCryCryCryCryCryCry
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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.


Edited by dj air - 19 January 2005 at 6:25am
Back to Top
neotrix View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 09 November 2003
Location: Pakistan
Status: Offline
Points: 433
Post Options Post Options   Thanks (0) Thanks(0)   Quote neotrix Quote  Post ReplyReply Direct Link To This Post 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


Edited by neotrix - 19 January 2005 at 11:21am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.