Hi guys!
how are you doing? I am coming up on a roadblock here in my SQL and would really appreciate any help that I can get. I am trying to develop an ecommerce website based on the sample northwind d'base in Access. At this point I am stuck on the query (sqlquery: shown below) that is supposed to check if a user has already bought a product and update the database accordingly. This query is triggered when the user clicks the 'buy' button from the previous asp page. My d'base has both a 'users' and a 'cart' table with the fields that are being requested.
The code is shown below:
Thanks for all your help guys, all the best!
<html>
<head>
<title>cart</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
dim prodid
dim prodname
dim prodprice
dim Connect
dim userID
ConnectString = "Provider = Microsoft.Jet.OLEDB.4.0;"_
& "Data Source = C:\NewNW.mdb"
Set Connect = Server.CreateObject("ADODB.Connection"
Connect.Open ConnectString
prodname = Request("productname"
prodid = Request("productid"
prodprice = Request("productprice"
Response.Write(prodname)
Response.Write(prodid)
Response.Write(prodprice)
IF prodid <> "" THEN
sqlquery = "SELECT cart_id FROM cart WHERE cart_userID = '" & userID & "'"
AND cart_productID ="'" & prodid &"'"
Set rsProductDisplay = Connect.Execute(sqlquery)
IF rsProductDisplay.EOF THEN
sqlquery = "INSERT INTO cart(cart_userID,cart_productID,cart_quantity)
VALUES(userID,prodid,1)"
ELSE
sqlString = "UPDATE cart SET cart_quantity = cart_quantity+1 WHERE cart_id
=" & rs("cart_id"&"'"
Connect.Execute(sqlString)
END IF
rsProductDisplay.Close
SET rsProductDisplay = nothing
END IF
%>
</body>
</html>
how are you doing? I am coming up on a roadblock here in my SQL and would really appreciate any help that I can get. I am trying to develop an ecommerce website based on the sample northwind d'base in Access. At this point I am stuck on the query (sqlquery: shown below) that is supposed to check if a user has already bought a product and update the database accordingly. This query is triggered when the user clicks the 'buy' button from the previous asp page. My d'base has both a 'users' and a 'cart' table with the fields that are being requested.
The code is shown below:
Thanks for all your help guys, all the best!
<html>
<head>
<title>cart</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
dim prodid
dim prodname
dim prodprice
dim Connect
dim userID
ConnectString = "Provider = Microsoft.Jet.OLEDB.4.0;"_
& "Data Source = C:\NewNW.mdb"
Set Connect = Server.CreateObject("ADODB.Connection"
Connect.Open ConnectString
prodname = Request("productname"
prodid = Request("productid"
prodprice = Request("productprice"
Response.Write(prodname)
Response.Write(prodid)
Response.Write(prodprice)
IF prodid <> "" THEN
sqlquery = "SELECT cart_id FROM cart WHERE cart_userID = '" & userID & "'"
AND cart_productID ="'" & prodid &"'"
Set rsProductDisplay = Connect.Execute(sqlquery)
IF rsProductDisplay.EOF THEN
sqlquery = "INSERT INTO cart(cart_userID,cart_productID,cart_quantity)
VALUES(userID,prodid,1)"
ELSE
sqlString = "UPDATE cart SET cart_quantity = cart_quantity+1 WHERE cart_id
=" & rs("cart_id"&"'"
Connect.Execute(sqlString)
END IF
rsProductDisplay.Close
SET rsProductDisplay = nothing
END IF
%>
</body>
</html>