error '80020009' help

I

isaac2004

hi i am creating a basic asp site that uses cookies to manage a cart
for an online store. whenever i open this page without adding anything
to the cart. i get an error message.

here is my code

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="DatabaseConnect.asp"-->
<!--#include virtual="06winter/levini/database/adovbs.inc"-->
<html>
<head><title>Shopping Cart</title>
<link rel="stylesheet" href="BookStore.css" type="text/css">
</head>
<table>

<!-- Header SSI starts here-->
<!--#include file="header.html"-->
<!-- Header SSI ends here-->
<!-- Author SSI begins here-->
<!--#include file="ListAuthors.asp"-->
<!-- Author SSI ends here-->
<%
'This shopping cart uses a cookie named "ShoppingCart"
'to store the ISBNs of the items in the cart.
'The cookie puts each ISBN value into a separate key named ISBN1,
ISBN2, etc.
'The current number of items in the cart is stored in a key named
"ItemCount"

dim ISBN, iItemCount, iItem, iCount, bFound, curPrice, curDiscPrice,
strSQL, objRS, strTitle, dblPrice, dblShipping, dblSubTotal,
dblTotalPrice

ISBN = trim(Request.QueryString("isbn"))


'sql statement for individual books
strSQL = "SELECT tblBookDescription.ISBN,
tblBookDescription.strTitle, tblBookDescription.strDescription,
tblBookDescription.strPublisher, tblBookDescription.dblPrice,
tblAuthors.AuthorID " & _
"FROM tblAuthors INNER JOIN (tblBookDescription INNER JOIN
tblAuthorsBooks ON tblBookDescription.ISBN = tblAuthorsBooks.ISBN) ON
tblAuthors.AuthorID = tblAuthorsBooks.AuthorID " & _
"WHERE (((tblBookDescription.ISBN)='" & ISBN & "')); "

response.write("strSQL = " & strSQL)


Set objRS = Server.CreateObject("ADODB.Recordset")

objRS.open strSQL, objConn


'Initialize iItemCount with number of books in the cart
If request.cookies("ShoppingCart").HasKeys then
iItemCount = request.cookies("ShoppingCart")("ItemCount")
else
'No cookie yet
iItemCount = 0
end if

'Add items to cart
If Request("action") = "add" and len(ISBN)>5 then
'add new item to ShoppingCart
iItemCount = iItemCount + 1
Response.cookies("ShoppingCart")("ISBN"&iItemCount) = ISBN
end if

'Delete items from Cart
If Request.QueryString("action") = "del" and len(ISBN)>5 then
'find the isbn
bFound = "False"
iItem = 1
Do while NOT bFound and iItem <= iItemCount
If Request.Cookies("ShoppingCart")("ISBN"&iItem) = ISBN then
bFound = "True"
else
iItem = iItem + 1
End If
Loop

If bFound then
'replace the deleted item with the item above it
iItemCount=iItemCount - 1
For iCount = iItem to iItemCount
Response.Cookies("ShoppingCart")("ISBN" &iCount)= _
Request.Cookies("ShoppingCart")("ISBN"&iCount+1)
Next
else
Response.write "Error: Could not match ISBN to delete."
end if
End If

'Update iItemCount
Response.Cookies("ShoppingCart")("ItemCount")=iItemCount
Response.Cookies("ShoppingCart").Expires = Date + 30

'
***********************************************************************************
' You do not need to modify anything above this line.
' You will need to modify the table below to list the items
' in your cart, calculate, total costs, etc.
'
***********************************************************************************

' list items in shopping cart
If iItemCount < 1 then
response.write "<center><font face='Comic Sans MS'
color='#FF0000'>" & _
"Your Shopping Cart is empty.</font><br><br>"
Else
%>
<div align="center">
<center>
<font face='Comic Sans MS' color='#FF0000'>You have <%
=iItemCount %>
book<% If iItemCount > 1 then response.write "s"%> in
your shopping cart.
</font><br><br>

<table border="0" cellpadding="5" cellspacing="0"
width="643">
<tr>
Book</font></td>
Quantity</font></td>
Price</font></td>
Remove</font></td>
</tr>
<%
'List each item in cart
For iCount = 1 to iItemCount
ISBN =
Request.Cookies("ShoppingCart")("ISBN"&iCount)
%>



<tr>
<td valign="top" width="20" >1.</td>
<td valign="top" width="256">
<! Book Title, author, stock >
<a href="ProductPage.asp?isbn= <% =objRS("ISBN")%> ">
<% =objRS("strTitle")%></a>
<br>
<font size="-1">
by <% =funListAuthors(objRS("ISBN")) %></a>
</font>
<br>
</td>
<td valign="top" align="center" width="66">1</td>
<td valign="top" width="179">
<! Price >
<FONT face=arial,verdana,helvetica><B>List Price:
<font color=#990000><strike><% =dblPrice
%></strike></font><br>

<FONT face=arial,verdana,helvetica>Our Price:
<font color=#990000><% =curDiscPrice %></font><br>

<FONT face=arial,verdana,helvetica>You Save:
<font color=#990000><% =FormatCurrency((dblPrice -
curDiscPrice)) %>(20%)</b></font><br><br>
</td>
<td valign="top" width="62" >
<a
href="ShoppingCart.asp?ISBN=<%=objRS("ISBN")%>&action=del"> Remove</a>
</td>
</tr>

<% Next
%> </table>
</center>
<%End If
%>
<tr>
<td></td><td></td><td></td>
<td>
<FONT face=arial,verdana,helvetica>
<table border="0" cellpadding="0" cellspacing="0"
width="150" >
<tr>
<% dim i
-----------------------------------------------------error here
curPrice = FormatCurrency(objRS("dblPrice"))
curDiscPrice = FormatCurrency((objRS("dblPrice")*.8))
dblPrice = (objRS("dblPrice"))

'response.write(iItemCount)
dblSubTotal = 0
for i = 1 to iItemCount
dblSubTotal = dblSubTotal + curDiscPrice
next

dblShipping = 3.49 + ((iItemCount - 1) * .99)

dblTotalPrice = dblShipping + dblSubTotal

if iItemCount = 0 then
response.write("<br>")
else
%>
<td width="75">Sub-Total:</td>
<td width="75"><p align="right"><%
=dblSubTotal%></td>
</tr>

<tr>
<td width="75">Shipping*:</td>
<td width="75"><p align="right"><% =dblShipping
%></td>
</tr>
<tr>
<td width="75">Total:</td>
<td width="75"><p align="right"><%
=dblTotalPrice%></td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>

<% end if%>

</table>
<br>
<div align="center">
<center>
<table border="0" cellpadding="5" cellspacing="0" width="400"
bgcolor="#99CCFF">
<tr>
<td><a href="default.asp"><img border="0"
src="/06Winter/levini/images/continue-shopping.gif" width="121"
height="19"></a><br>
</td>
<td>
<p align="right"><a href="checkout.asp"><img border="0"
src="/06Winter/levini/images/proceed-to-checkout.gif" width="183"
height="31"></a>
</td>
</tr>
</table>

<table border="0" cellpadding="5" cellspacing="0" width="400">
<tr>
<td> <br><p align=center> Shipping is $3.49 for the first book
and $.99 for each additional book. To assure reliable delivery and
to keep your costs low we send all books via UPS ground.
</td>
</tr>
</table>
</body>
</html>


any help would be much appreciated thank you
 
P

Paxton

isaac2004 said:
hi i am creating a basic asp site that uses cookies to manage a cart
for an online store. whenever i open this page without adding anything
to the cart. i get an error message.
<% dim i
-----------------------------------------------------error here
curPrice = FormatCurrency(objRS("dblPrice"))
curDiscPrice = FormatCurrency((objRS("dblPrice")*.8))
dblPrice = (objRS("dblPrice"))

'response.write(iItemCount)
dblSubTotal = 0
for i = 1 to iItemCount
dblSubTotal = dblSubTotal + curDiscPrice
next

That's because you are trying to do something with a record that
doesn't exist. You need to partition this part of the code off so
that it only runs if you have something in the cart.

Pseudo code...

If something in the cart then
do some stuff with the records
End if

/P.
 
P

Paxton

isaac2004 said:
hi i am creating a basic asp site that uses cookies to manage a cart
for an online store. whenever i open this page without adding anything
to the cart. i get an error message.

here is my code

Some more advice for you to help with development/debugging:

1. Remove ALL tables and presentational markup from your page until
you know that the ASP code is working properly.

2. Don't include adovbs.inc unless you use it. So far you've only used
default cursors, so it's not needed in the examples you've given.

3. Test the values of your variables thoughout the code using
response.write var & "<br>". That way you'll know whether the code is
working correctly.

4. When you do put the presentational html in, make use of the css file
you've included.

This sort of thing:
<FONT face=arial,verdana,helvetica><B>List Price:
<font color=#990000><strike><% =dblPrice %></strike></font>

is terrible. It should be put in the css file:

..strike {
text-decoration: line-through;
font family: arial,verdana,helvetica;
font-weight: bold;
}

Then you use it like so: <span class="strike"><% =dblPrice %></span>.
This will greatly reduce the amount of html code in your page and make
it much easier to tell what's what.

5. Check your html. Currently, you have no <body> tag in your document
at all. You have opened a table in another table, without putting the
second table in a td. Some browsers may display this as you intend,
but some others may not display it at all. You also have some divs
that overlap and unclosed tags.

HTH

/P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top