hi guys, i'm trying to fix this problem and i don't know how...
i have the global.asa as follows:
addtocart.asp
this writes to the database whenever a visitor uses the shopping cart and not proceeding to the checkout, it always leaves 1 as orderID which i need to clean.
how can i clean it automatically ?
also another problem is that the shopping cart is meant to open different sessions for different visitors, meaning that each visitor starts with an empty cart, right????
well my cart does not work like that ?
how can i fix that ?
should i fix this from the global.asa or what ?
please help me with this one.....
thx
i have the global.asa as follows:
Code:
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
'You can add special event handlers in this file that will get run automatically when
'special Active Server Pages events occur.
'EventName Description
'Session_OnStart Runs the first time a user runs any page in your application
'Session_OnEnd Runs when a user's session times out or quits your application
'Application_OnStart Runs once when the first page of your application is run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down
Sub Application_OnStart
'==Visual InterDev Generated - startspan==
'-- Project Data Environment
'Set DE = Server.CreateObject("DERuntime.DERuntime")
'Application("DE") = DE.Load(Server.MapPath("Global.ASA"), "_private/DataEnvironment/DataEnvironment.asa")
'==Visual InterDev Generated - endspan==
'Password protect your database and then substitute the password for "foo" in the code below
Dim vPath, pPath, ConString
vPath = "db/shop.mdb" 'use this one if database is in root of cart folder
'vPath = "db/shop.mdb" 'use this one if database is in root of your website
pPath = Server.MapPath( vPath )
ConString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:Database Password=foo"
Application("visits") = 0
Application("Active") = 0
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConString
set rsMaxOrder = Conn.Execute("select orderID from" _
& " orders " & "order by orderID desc")
if rsMaxOrder.EOF then
Application("orderID") = 1
else
Application("orderID") = rsMaxOrder("orderID") + 1
end if
rsMaxOrder.Close
set rsMaxOrder = Nothing
Conn.Close
set Conn = Nothing
End Sub
Sub Session_OnStart
Session("Start") = Now
Application.lock
Application("visits") = Application("visits") + 1
intTotal_visitors = Application("visits")
Application.unlock
Session("VisitorID") = intTotal_visitors
Application.lock
Application("Active") = Application("Active") + 1
Application.unlock
End Sub
Sub Session_OnEnd
Application.lock
Application("Active") = Application("Active") - 1
Application.unlock
End Sub
</SCRIPT>
addtocart.asp
Code:
<%@ Language=VBScript %>
<!-- #include file="db.asp" -->
<!-- #include file="adovbs.inc" -->
<%
Dim Conn
Sub CreateNewOrder()
Application.lock
if Application("orderID") = "" then
Application("orderID") = 1
end if
intOrderID = Application("orderID")
Session("orderID") = intOrderID
Conn.Execute("INSERT INTO orders " _
& " (orderID, status) values " _
& " ("&intOrderID&", 'OPEN')")
Application("orderID") = Application("orderID") + 1
Application.Unlock
End Sub
Sub AddToOrder(nOrderID, nProductID, nQuant)
sqlText = "INSERT INTO itemsOrdered " _
& " (orderID, productID, quantity) values " _
& " ("&nOrderID&", "&nProductID&", "&nQuant&")"
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
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
else
txtInfo = "This item is already in your cart."
end if
%>
this writes to the database whenever a visitor uses the shopping cart and not proceeding to the checkout, it always leaves 1 as orderID which i need to clean.
how can i clean it automatically ?
also another problem is that the shopping cart is meant to open different sessions for different visitors, meaning that each visitor starts with an empty cart, right????
well my cart does not work like that ?
how can i fix that ?
should i fix this from the global.asa or what ?
please help me with this one.....
thx
