<%@ Language=VBScript %> <%producttype = request("producttype") 'response.Write(producttype) %> <% pageTitle = "Add To Cart" %> <% '****************************************************** 'Copyrightę2000-2002 MetaLinks.com @ http://metalinks.com '****************************************************** intProdId = Request.QueryString("pid") session.timeout = 400 intOrderID = Application("orderID") intOrderID = Session("orderID") if intOrderID = "" then conn.execute("update order_seq set order_seq = order_seq +1") set rsMaxOrder = conn.execute("select order_seq from order_seq") intOrderID = rsMaxOrder(0) Session("orderID") = intOrderID Conn.Execute("INSERT INTO orders " _ & " (orderID, status) values " _ & " ("&intOrderID&", 'OPEN')") else intOrderID = Session("orderID") end if Quant = 1 Sub AddToOrder(nOrderID, nProductID, nQuant) sqlText = "INSERT INTO itemsOrdered " _ & " (orderID, productID, quantity) values " _ & " ("&nOrderID&", "&nProductID&", "& Quant &")" Conn.Execute(sqlText) End Sub 'Main program intProdID = Request.Form("intProdID") intQuant = Request.form("intQuant") 'set Conn = Server.CreateObject("ADODB.Connection") 'Conn.Open ConString intOrderID = cstr(Session("orderID")) if intOrderID = "" then CreateNewOrder end if intProdId = Request.QueryString("pid") sqlText = "SELECT * FROM itemsOrdered WHERE orderID =" & intOrderID & "AND productID =" & intProdID set rsOrder = Conn.Execute(sqlText) if rsOrder.EOF then 'txtInfo = "This item has been added to your order." AddToOrder intOrderID, intProdID, intQuant Conn.Close set Conn = Nothing response.Redirect("addcart.asp?producttype="& producttype) else Quant = rsOrder("quantity") upid = rsOrder("productid") Quant = Quant + 1 response.write(Quant) sqlins = "update itemsordered set quantity = "& Quant &" where productid = "& upid &" " conn.execute(sqlins) Conn.Close set Conn = Nothing response.Redirect( "addcart.asp?producttype="& producttype) end if %>