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

access database query

Status
Not open for further replies.

JAguy

Technical User
Mar 11, 2002
1
US
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=&quot;Content-Type&quot; content=&quot;text/html;
charset=iso-8859-1&quot;>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>

<%
dim prodid
dim prodname
dim prodprice
dim Connect
dim userID

ConnectString = &quot;Provider = Microsoft.Jet.OLEDB.4.0;&quot;_
& &quot;Data Source = C:\NewNW.mdb&quot;
Set Connect = Server.CreateObject(&quot;ADODB.Connection&quot;)
Connect.Open ConnectString


prodname = Request(&quot;productname&quot;)
prodid = Request(&quot;productid&quot;)
prodprice = Request(&quot;productprice&quot;)


Response.Write(prodname)
Response.Write(prodid)
Response.Write(prodprice)

IF prodid <> &quot;&quot; THEN

sqlquery = &quot;SELECT cart_id FROM cart WHERE cart_userID = '&quot; & userID & &quot;'&quot;
AND cart_productID =&quot;'&quot; & prodid &&quot;'&quot;
Set rsProductDisplay = Connect.Execute(sqlquery)

IF rsProductDisplay.EOF THEN

sqlquery = &quot;INSERT INTO cart(cart_userID,cart_productID,cart_quantity)
VALUES(userID,prodid,1)&quot;

ELSE
sqlString = &quot;UPDATE cart SET cart_quantity = cart_quantity+1 WHERE cart_id
=&quot; & rs(&quot;cart_id&quot;)&&quot;'&quot;
Connect.Execute(sqlString)
END IF
rsProductDisplay.Close
SET rsProductDisplay = nothing

END IF


%>


</body>
</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top