Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-03, 12:28
arif arif is offline
Registered User
 
Join Date: Oct 2002
Posts: 4
ASP Error

Hello,

I am constructing a web site for a project, with a shopping cart. Now the shoping cart has 3 main functions: (1) add more products, (2) proceed to checkout and (3) update the quantities of a product. The first two work fine but i am having problems with the last function. Whenever you attempt to update the quantity of a product (whether adding or subtracting), it simply deletes all items in the shopping cart. I would be very grateful if anyone could help with any ideas, heres the code for updating the product quantities:

' Update Shopping Cart Quantities
IF Request( "updateQ" ) <> "" THEN
SET RS = Server.CreateObject( "ADODB.Recordset" )
RS.ActiveConnection = Con
RS.CursorType = adOpenDynamic
RS.LockType = adLockOptimistic
sqlString = "SELECT cart_id, cart_quantity FROM cart " &_
"WHERE cart_userID=" & userID
RS.Open sqlString
WHILE NOT RS.EOF
newQ = TRIM( Request( "pq" & RS( "cart_id" ) ) )
deleteProduct = TRIM( Request( "pq" & RS( "cart_id" ) ) )
IF newQ = "" OR newQ = "0" THEN
RS.Delete
ELSE
IF isNumeric( newQ ) THEN
RS( "cart_quantity" ) = newQ
END IF
END IF
RS.MoveNext
WEND
RS.Close
SET RS = Nothing
END IF

Thank you.
Reply With Quote
  #2 (permalink)  
Old 04-20-03, 04:42
Memnoch1207 Memnoch1207 is offline
Registered User
 
Join Date: Jan 2003
Location: Midwest
Posts: 138
I do mine a little differently I add the items to a dictionary object and update them this way.

Code:
if(Trim(Request("update")) <> "") then for each x in Request.Form if Left(x, 4) = "qty_" then current = Split(x, "_") if IsNumeric(Request(x)) then if CInt(Request(x)) = 0 then cartObj_count.Remove(CStr(current(1))) cartObj_orderNum.Remove(CStr(current(1))) cartObj_des.Remove(CStr(current(1))) cartObj_price.Remove(CStr(current(1))) cartObj_stock.Remove(CStr(current(1))) cartObj_weight.Remove(CStr(current(1))) cartObj_handling.Remove(CStr(current(1))) else cartObj_count(CStr(current(1))) = CInt(Request(x)) end if end if end if next end if
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On