Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using value from database updating the database and resuing the value

Status
Not open for further replies.

adeelchaudry

Programmer
Dec 13, 2006
2
US
i wrote a shopping cart using cookies found out thatIE 7 won't let me add more cookies after a certian number. decided to use DB along with cookies and now i have very weired problem never encountered before

code:
line 1: response.Cookies("cart") ("total_item") = Cint(request.Cookies("cart") ("total_item")) - Cint(CartRs("item_Quantity"))
line 2: response.Cookies("cart") ("total_item") = Cint(request.Cookies("cart") ("total_item")) + item_Quantity
line 3: response.Cookies("cart")("total") = Cint(request.Cookies("cart")("total")) - (Cint(CartRs("item_Quantity"))*Cint(CartRs("item_price")))
line 4: response.Cookies("cart")("total") = Cint(request.Cookies("cart")("total")) + Cint((item_Quantity*Cint(CartRs("item_price"))))
line 5: CartRs("item_Quantity")= item_Quantity
CartRs.update


item_Quantity is initially assigned the value from the previous page (form field) which contains the changes item Quantity.
Line 1: i am subtracting the stored item Quantity(from the DB) from the cookie which stores the total items in cart and on line 5 i am updating DB with the new value for item_Quantity what i don't understand on line 1 instead of using the old value for item_Quantity from database it is using the updated value but i am not updating the DB unltil line 5 i though asp loads from top to bottom what am i missing why am i having this behaviour. i will really appreciate any help/light on this matter.

Thanks
 
Debug. What are the initial values of item_Quantity and CartRs("item_Quantity"). They could be the same value, it doesn't mean that you are using the new value.

It is possible that the DB value is 5 and the value from your previous page is 5.
 
no they are not same i have debuged a lot and i am sure it is using the updated value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top