adeelchaudry
Programmer
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
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