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

recalculate page shows Cannot Display

Status
Not open for further replies.

NhaTrang

IS-IT--Management
Feb 21, 2003
8
US
This problem has been bugging me for a while now. Whenever the qty in the cart is updated with the qty, the "Cannot display the page" message is returned.
Also, my company's website shoppingcart works for certain customers who have made purchases before, not for others even though they are logged in and ready to make purchase. Basically the items from the shopping cart are not shown up in the checkout page when. I am a newbie to ASP and currently a new maitainer of the website. Your help will be greatly appreciated.
My recalc.asp code:
<% Response.Buffer = True

Set ConnObj = Server.CreateObject("ADODB.Connection")
ConnObj.Mode = adModeWrite
' ConnObj.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("../../database/invatec.mdb")
ConnObj.Open "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=HIDA-TEST3;User ID=*****;Password=*****"


for i = 1 to request.form("itemcnt")
if request.form("Quantity" & i ) > "" and isnumeric(request.form("Quantity" & i )) and request("onhand" & i ) > "" and isnumeric(request("onhand" & i )) then
newqty = cint(request("Quantity" & i ))
onhand = cint(request("onhand" & i ))

if newqty > onhand then
newqty = onhand
end if

neworder = request.form("Order" & i)

CommandText = "UPDATE [Order] SET [Order].Quantity = " & newqty
if request("cost_bid"& i)>"" and isnumeric(request("cost_bid"& i)) then
CommandText=CommandText & ", Cost_Bid=" & request("cost_bid"& i)
if request("cost_bid"& i) >= request("cost"& i) then
CommandText=CommandText & ", status='Shopping' "
end if
end if
CommandText=CommandText & " WHERE (((Order.OrderID)= " & neworder & "))"
'response.write (CommandText)
ConnObj.Execute(CommandText)
end if
next

response.redirect("/cart.asp")
%>

My cart.asp code:
<% DBPath = "../database/invatec.mdb" %>
<!--#include virtual="/modules/checksession.asp"-->
<%
Response.Expires=0
%>

<%
' invconn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("../database/invatec.mdb")
invconn = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=HIDA-TEST3;User ID=*****;Password=*****"
Set rsInvatec3 = Server.CreateObject ("ADODB.Recordset")
SQLstr3="Select * From [Order] Where (Status='Shopping' or Status='Bid') and BuyerID=" & Session("CustomerID") & " order by vendor"
rsInvatec3.Open SQLstr3, invconn, 0, 1
if not(rsInvatec3.EOF or rsInvatec3.BOF) then
TotalCost = 0
SubTotal = 0
cntr = 1
do while not rsInvatec3.EOF
SubTotal = (rsInvatec3("Cost") * rsInvatec3("Quantity"))
TotalCost = TotalCost + SubTotal
%>

My checksession.asp code:
<!-- #include virtual="/adovbs.inc" -->
<%
response.Expires=0
response.buffer = true

' check for session variables[done]
' if they exist then move on
if not Session("ID")>"" or request("Login") > "" then
if Request.Cookies("SavedLogin")("ID")>"" then ' was here before
UserID=Request.Cookies("SavedLogin")("ID")
Password=Request.Cookies("SavedLogin")("Pass")
end if
if request("Login") > "" then ' logged in from screen
UserID=request("Login")
Password=request("Password")
end if
if Session("regLogin") > "" and Session("regPassword") > "" then
UserID = Session("regLogin")
Password = Session("regPassword")

Session("regLogin") = ""
Session("regPassword") = ""
end if
if UserID > "" and Password > "" then
' Conn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath( DBPath )
Conn = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=HIDA-TEST3;User ID=*****;Password=*****"
Set rsPassword = Server.CreateObject ("ADODB.Recordset")
SQLstr="Select * from Customers where Status='Active' and UserID='" & UserID & "' and Password='" & Password & "'"
' rsPassword.Open SQLstr, Conn, 3, 3
rsPassword.Open SQLstr, Conn, adOpenStatic, adLockReadOnly

if rsPassword.RecordCount > 0 then
' set session variables
Session("ID") = UserID
Session("Pass") = Password
Session("CompanyName") = rsPassword("Customer")
Session("CustomerID") = rsPassword("CustomerID")
Session("IDTMember") = rsPassword("IDTMember")
Session("UserLoggedIn") = true
' set cookies
Response.Cookies("SavedLogin")("ID") = UserID
Response.Cookies("SavedLogin")("Pass") = Password
Response.Cookies("SavedLogin").Expires = Date + 30
else
Session("Message") = "<br><img src='/img/transupply.gif' width='4' height='4' border='0'>Incorrect Login/Password"
response.redirect ("/register.asp")
end if
rsPassword.Close
set rsPassword = Nothing
else
Session("UserLoggedIn") = false
end if
end if
if Session("UserLoggedIn") = true then
' invconn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath( DBPath )
invconn = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=HIDA-TEST3;User ID=*****;Password=*****"

Set rsInvatec3 = Server.CreateObject ("ADODB.Recordset")
SQLstr3="Select * From [Order] Where (Status='Shopping' or Status='Bid') and BuyerID=" & Session("CustomerID") & " order by vendor"
rsInvatec3.Open SQLstr3, invconn, 0, 1
if not(rsInvatec3.EOF or rsInvatec3.BOF) then
Session("CartItems") = true
else
Session("CartItems") = false
end if
rsInvatec3.Close
set rsInvatec3 = Nothing
end if
%>
 
Hmmmm... long post.

without spending too long on it I notice that the form variables are not referenced the same every time:
sometimes it has:
request.form("Quantity" & i)
while other times it has
request("Quantity" & i)

I would recommend changing all references to form variables to: request.form("name")

If it becomes very difficult to track down I would recommend building a small logging tool for this page. Every time someone hits it save the form submission and session variables to a log file (text, or DB table)





Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Thanks for your answer, Travis. I changed the references you recommended in the recalc.asp script. But it still does not work. Could you show me how and where to start building the loggin tools for this form?
Thankx
 
just a thought after a quick glance..

What do mean by this:
if request.form("Quantity" & i ) > ""

did u mean the vairable i greater than null ??

you might want to try variable not equal to null...

if request.form("Quantity" & i ) <> ""



-VJ
 
Hi VJ-
i = itemline. The if statement looks into the qty variable for each item line in the cart.
 
hey,

amorous is right.
That check for an empty variable is kind of funky.

Another thing I noticed is that you loop through the form variables based on request.form("itemcnt"), have you verified that this form variable is carrying the correct value?

It may be better to loop through the Form object. What I do is name my form variables Name_ID. So You would have:
Quantity_1
Quantity_2
onhand_1
onhand_2
Then loop through like this:
Code:
  for each FrmVar in Request.Form
    FV = split(FrmVar,"_");
    response.write " Form Field: " & FrmVar &_
                   " Name: " & FV[0] &_
                   " Number: " & FV[1] &_
                   " Value: " & request.form(FrmVar) &_
                   "<br>" 
  next

This should give you a better idea of what is going on with your form variables. You may be able to find what the problem is that way.

Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Thank you Travis. I will let you how this works out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top