Hi
for the last few months i've just stuck in 1 error & i don't know how to figer it out
could any body find out where is the problem gonna be ?
it's working fine but when u add product into basket it's bring automatically 1 extra product some time 2 or some time it's working fine i think so problem with GLOBAL.asa File that's not generating proper session variable
GLOBAL.asa
[code=asp]
Sub Application_OnS tart
CStr = "PROVIDER=MICRO SOFT.JET.OLEDB. 4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:Database Password=foo"
Application("vi sits") = 0
Application("Ac tive") = 0
set Conn = Server.CreateOb ject("ADODB.Con nection")
Conn.Open CStr
set rsMaxOrder = Conn.Execute("s elect orderID from" _
& " orders " & "order by orderID desc")
if rsMaxOrder.EOF then
Application("or derID") = 1
else
Application("or derID") = rsMaxOrder("ord erID") + 1
end if
rsMaxOrder.Clos e
set rsMaxOrder = Nothing
Conn.Close
set Conn = Nothing
End Sub
Sub Session_OnStart
Session("Start" ) = Now
session("uname" )=""
Application.loc k
Application("vi sits") = Application("vi sits") + 1
intTotal_visito rs = Application("vi sits")
Application.unl ock
Session("Visito rID") = intTotal_visito rs
Application.loc k
Application("Ac tive") = Application("Ac tive") + 1
Application.unl ock
End Sub
Sub Session_OnEnd
Application.loc k
Application("Ac tive") = Application("Ac tive") - 1
Application.unl ock
session("uname" )=""
If Not Application(Ses sion.SessionID) = "" Then
Application(Ses sion.SessionID) = ""
End If
End Sub
[/code]
---------------------------------------------------------
Before i add product into the basket there is no item shown into the basket
But when i add product into the basket & after that review then it's create the problem .
There is 2 files
1 - add_to_cart.asp
2 - review_order.as p
_______________ _______________ _______________ ____________
[code=asp]
<!-- #include file="database. asp" -->
<!-- #include file="adovbs.in c" -->
<%
Sub CreateNewOrder( )
Application.loc k
if Application("or derID") = "" then
Application("or derID") = 1
end if
intOrderID = Application("or derID")
Session("orderI D") = intOrderID
Conn.Execute("I NSERT INTO orders " _
& " (orderID, status) values " _
& " ("&intOrderID&" , 'OPEN')")
Application("or derID") = Application("or derID") + 1
Application.Unl ock
End Sub
Sub AddToOrder(nOrd erID, nProductID, nQuant)
sqlText = "INSERT INTO itemsOrdered " _
& " (orderID, productID, quantity) values " _
& " ('"&nOrderID&"' , '"&nProductID&" ', '"&nQuant&"' )"
Conn.Execute(sq lText)
End Sub
'Main program
intProdID = Request.form("i ntProdID")
intQuant = Request.form("i ntQuant")
set Conn = Server.CreateOb ject("ADODB.Con nection")
Conn.Open ConString
intOrderID = cstr(Session("o rderID"))
if intOrderID = "" then
CreateNewOrder
end if
sqlText = "SELECT * FROM itemsOrdered WHERE orderID =" & intOrderID & "AND productID =" & intProdID
set rsOrder = Conn.Execute(sq lText)
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
%>
<html>
<head>
</head>
<body>
<a href="review_Or der.asp">review order</a>
<%
Conn.Close
set Conn = Nothing
%>
</font></td></tr></table> </body></html>[/code]
_______________ _______________ _______________ ___________
2 - review_order.as p
[code=asp]
<%@ Language=VBScri pt %>
<% pageTitle = "Review Order" %>
<!-- #include file="database. asp" -->
<!-- #include file="adovbs.in c" -->
<html>
<head>
</head>
<body>
<%
set Conn = Server.CreateOb ject("ADODB.Con nection")
Conn.Open ConString
if cstr(Session("o rderID")) = "" then
Response.Write "There is no current order." & "<br>"
else
intOrderID = cstr(Session("o rderID"))
sqlText = "select products.produc tID, productName, " _
& "productPri ce, quantity from products, " _
& "itemsOrder ed where " _
& "products.produ ctID = itemsOrdered.pr oductID "_
& "and itemsOrdered.or derID = " & intOrderID
%>
<%
set rsReview = Conn.Execute(sq lText)
while not rsReview.EOF
intProdID = rsReview("produ ctID")
strProdName = rsReview("produ ctName")
intProdPrice = rsReview("produ ctPrice")
intQuant = rsReview("quant ity")
intTotal = intTotal + (intQuant * intProdPrice)
%>
<input name="quant<%= intProdID %>" value=" <%=intQuant%>"> <br>
<%= strProdName %> £<%= formatNumber(in tProdPrice, 2) %>
<%
rsReview.MoveNe xt
wend
rsReview.Close
set rsReview = Nothing
%>
<input type="submit" name="control" value="Update Order">
<input type="submit" name="control" value="Go To Check-Out">
<%
end if
Conn.Close
set Conn = Nothing
%>
</body></html>[/code]
Thanks in advance
for the last few months i've just stuck in 1 error & i don't know how to figer it out
could any body find out where is the problem gonna be ?
it's working fine but when u add product into basket it's bring automatically 1 extra product some time 2 or some time it's working fine i think so problem with GLOBAL.asa File that's not generating proper session variable
GLOBAL.asa
[code=asp]
Sub Application_OnS tart
CStr = "PROVIDER=MICRO SOFT.JET.OLEDB. 4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:Database Password=foo"
Application("vi sits") = 0
Application("Ac tive") = 0
set Conn = Server.CreateOb ject("ADODB.Con nection")
Conn.Open CStr
set rsMaxOrder = Conn.Execute("s elect orderID from" _
& " orders " & "order by orderID desc")
if rsMaxOrder.EOF then
Application("or derID") = 1
else
Application("or derID") = rsMaxOrder("ord erID") + 1
end if
rsMaxOrder.Clos e
set rsMaxOrder = Nothing
Conn.Close
set Conn = Nothing
End Sub
Sub Session_OnStart
Session("Start" ) = Now
session("uname" )=""
Application.loc k
Application("vi sits") = Application("vi sits") + 1
intTotal_visito rs = Application("vi sits")
Application.unl ock
Session("Visito rID") = intTotal_visito rs
Application.loc k
Application("Ac tive") = Application("Ac tive") + 1
Application.unl ock
End Sub
Sub Session_OnEnd
Application.loc k
Application("Ac tive") = Application("Ac tive") - 1
Application.unl ock
session("uname" )=""
If Not Application(Ses sion.SessionID) = "" Then
Application(Ses sion.SessionID) = ""
End If
End Sub
[/code]
---------------------------------------------------------
Before i add product into the basket there is no item shown into the basket
But when i add product into the basket & after that review then it's create the problem .
There is 2 files
1 - add_to_cart.asp
2 - review_order.as p
_______________ _______________ _______________ ____________
[code=asp]
<!-- #include file="database. asp" -->
<!-- #include file="adovbs.in c" -->
<%
Sub CreateNewOrder( )
Application.loc k
if Application("or derID") = "" then
Application("or derID") = 1
end if
intOrderID = Application("or derID")
Session("orderI D") = intOrderID
Conn.Execute("I NSERT INTO orders " _
& " (orderID, status) values " _
& " ("&intOrderID&" , 'OPEN')")
Application("or derID") = Application("or derID") + 1
Application.Unl ock
End Sub
Sub AddToOrder(nOrd erID, nProductID, nQuant)
sqlText = "INSERT INTO itemsOrdered " _
& " (orderID, productID, quantity) values " _
& " ('"&nOrderID&"' , '"&nProductID&" ', '"&nQuant&"' )"
Conn.Execute(sq lText)
End Sub
'Main program
intProdID = Request.form("i ntProdID")
intQuant = Request.form("i ntQuant")
set Conn = Server.CreateOb ject("ADODB.Con nection")
Conn.Open ConString
intOrderID = cstr(Session("o rderID"))
if intOrderID = "" then
CreateNewOrder
end if
sqlText = "SELECT * FROM itemsOrdered WHERE orderID =" & intOrderID & "AND productID =" & intProdID
set rsOrder = Conn.Execute(sq lText)
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
%>
<html>
<head>
</head>
<body>
<a href="review_Or der.asp">review order</a>
<%
Conn.Close
set Conn = Nothing
%>
</font></td></tr></table> </body></html>[/code]
_______________ _______________ _______________ ___________
2 - review_order.as p
[code=asp]
<%@ Language=VBScri pt %>
<% pageTitle = "Review Order" %>
<!-- #include file="database. asp" -->
<!-- #include file="adovbs.in c" -->
<html>
<head>
</head>
<body>
<%
set Conn = Server.CreateOb ject("ADODB.Con nection")
Conn.Open ConString
if cstr(Session("o rderID")) = "" then
Response.Write "There is no current order." & "<br>"
else
intOrderID = cstr(Session("o rderID"))
sqlText = "select products.produc tID, productName, " _
& "productPri ce, quantity from products, " _
& "itemsOrder ed where " _
& "products.produ ctID = itemsOrdered.pr oductID "_
& "and itemsOrdered.or derID = " & intOrderID
%>
<%
set rsReview = Conn.Execute(sq lText)
while not rsReview.EOF
intProdID = rsReview("produ ctID")
strProdName = rsReview("produ ctName")
intProdPrice = rsReview("produ ctPrice")
intQuant = rsReview("quant ity")
intTotal = intTotal + (intQuant * intProdPrice)
%>
<input name="quant<%= intProdID %>" value=" <%=intQuant%>"> <br>
<%= strProdName %> £<%= formatNumber(in tProdPrice, 2) %>
<%
rsReview.MoveNe xt
wend
rsReview.Close
set rsReview = Nothing
%>
<input type="submit" name="control" value="Update Order">
<input type="submit" name="control" value="Go To Check-Out">
<%
end if
Conn.Close
set Conn = Nothing
%>
</body></html>[/code]
Thanks in advance
Comment