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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update sql problem 1

Status
Not open for further replies.

xue

Programmer
Feb 5, 2001
12
0
0
US
I am trying to update the quantity on cartitems table:

Set rs3 = conn.Execute("UPDATE CartItems SET Qty = Qty + '" & CtempQty & "' WHERE Cartid = '" & cartID & "' And Productid = '" & s & "' ")
actually concat strings, so instead of 3+3, now it is 33

Set rs3 = conn.Execute("UPDATE CartItems SET Qty = Qty + & CtempQty & WHERE Cartid = '" & cartID & "' And Productid = '" & s & "' ")
gives syntax error near & error message

Set rs3 = conn.Execute("UPDATE CartItems SET Qty = Qty + "& CtempQty &" WHERE Cartid = '" & cartID & "' And Productid = '" & s & "' ") or
Set rs3 = conn.Execute("UPDATE CartItems SET Qty = Qty + '& CtempQty &' WHERE Cartid = '" & cartID & "' And Productid = '" & s & "' ")
are both not working, but:
Set rs3 = conn.Execute("UPDATE CartItems SET Qty = Qty + 1 WHERE Cartid = '" & cartID & "' And Productid = '" & s & "' ")
does increment 1 to the quantity(Qty).

so how can I add the CtempQty, which is the request.form("qty") to the quantity, which is Qty to the table? thank you very much.
 
Ok, this is what you have :
In the following query there is a syntax error - you have quotes surrounding the variable CtemQty.
Set rs3 = conn.Execute("UPDATE CartItems SET Qty = Qty + '" & CtempQty & "' WHERE Cartid = '" & cartID & "' And Productid = '" & s & "' ")

That was the first query. In fact I did find syntax errors in all the queries. What you need to do is something like this :

Set rs3 = conn.Execute("UPDATE CartItems SET Qty = Qty + " & CtempQty & " WHERE Cartid = '" & cartID & "' And Productid = '" & s & "' ")


Lemme know if it worked.
 
sorry to get back to you so late. yes, it works. thank you very much. the problem is I need to have space between " and &
it just have to be so precise, huh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top