Forum Moderators: open

Message Too Old, No Replies

ASP Multiple Pages

         

Mosha

12:14 am on Mar 14, 2004 (gmt 0)

10+ Year Member



Hello all, i'm attempting to diplay data across multiple pages, and have produced some code to do just that, but there is a problem that i'm hoping someone can help with, i've tried no end to sort it but yet no luck, I'm not by any means proficient in ASp.

I'M REALLY SORRY ABOUT THE LENGTH OF THE CODE, BUT I THINK ITS ALL NECESSARY IF ANYONE IS TO HELP
______________________________________________________
The problem is when i run the page, it displays multiple pages fine, but the script for some reason give me a link to a page '0' which gives the following error:

ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another

and a last page numbered whatever that gives this error

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

The code for the page is as follows:
______________________________________________________
<!-- #INCLUDE FILE="adovbs.inc" -->
<%
' Retrieves the current page

pg = TRIM( Request( "pg" ) )

IF pg = "" THEN pg = 1

'Open the recordset
Set prodRS = Server.CreateObject( "ADODB.Recordset" )
prodRS.ActiveConnection = Con
prodRS.CursorType = adOpenStatic
prodRS.PageSize = 5

sql = "SELECT product_id, product_picture, product_name, product_briefDesc, product_category, product_price " &_
"FROM Products WHERE product_category='" & cat & "' " &_
"AND product_status=1 " &_
"ORDER BY product_name "
prodRS.Open sql
prodRS.AbsolutePage = pg
%>

<table width="96%" border=0
cellpadding=5 cellspacing=0>
<%
WHILE NOT prodRS.EOF AND rowCount < prodRS.PageSize
rowCount = rowCount + 1
%>
<tr>
<td width="21%" rowspan="6">
<% IF prodRS( "product_picture" ) <> "?" THEN %>
<IMG SRC="<%=prodRS( "product_picture" )%>"
HSPACE=4 VSPACE=4 BORDER=0 align="center" height="150" width="100"><% END IF %>
</td>
</tr>
<tr>
<td colspan="2">
<a href="product.asp?pid=<%=prodRS( "product_id" )%>" target="_blank">
<b><%=prodRS( "product_name" )%></b></a>
<div align="right"></td>
</tr>
<td width="33%">&nbsp;</td>
<td width="46%" align="right">
<em>Category:</em> <font color="#33547B"><strong><%=prodRS( "product_category" )%></strong></font></div>
</td>
</tr>
<tr>
<td colspan="2">
<%=prodRS( "product_briefDesc" )%>
</td>
</tr>
<tr>
<td colspan="1">
<a href="product.asp?pid=<%=prodRS( "product_id" )%>" target="_blank">
<strong>Get More Information</strong></a>
</td>
<td>
<div align="right"><span style="font-weight: bold; color: #33547B;"><i>MovieNation Price:</span> <b><font color="#FF9966">£<%=prodRS( "product_price" )%></font></i></b></div>
</td>
</tr>
<tr>

<%
prodRS.MoveNext
WEND
%>
</table>

<%
IF prodRS.PageCount > 1 THEN
%>

<font color="#3366FF">
<b>Go To Page:</b>
<%
FOR i = i to ProdRS.PageCount
IF i <> cINT( pg ) THEN
%>
<a href="dvdhome.asp?cat=<%=prodRS( "product_category" )%>&pg=<%=i%>">
<%=i%></a>&nbsp;
<% ELSE %>
<b> <%=i%> </b> &nbsp;
<%
END IF
%>
<%
NEXT
%>
</font>
<%
END IF
%>

Please help me, i just can't see whats causing it

Thankyou

Tom

duckhunter

3:04 am on Mar 14, 2004 (gmt 0)

10+ Year Member



If that's all the code, looks like you need to create and open the connection before Opening the Recordset.

'Open the connection
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open

Mosha

12:00 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



DuckHunter I tried what you suggested and where i executed the script got this error, i belive there is something i've done in the script that is giving me this sort of page numbering

0 1 2 3 4

With the first and last page giving the respected errors mentioned in my first post, i suppose its not a big thing, but i have to hand this in on Wednesday for a project and well thought they might penalise me for a simple error like this.

Hope you can help

Thanks

Tom

Staffa

9:08 pm on Mar 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If this is all your code than I notice two things :

1. close your RS. and set to nothing
and close your Con and set to nothing

2. In your sql statement you refer to cat but I cannot find a definition for what cat is, ie
DIM cat
cat = request.form("whatever") or something similar.

 "FROM Products WHERE product_category='" & cat & "' " &_ 

Hope this helps

Mosha

11:55 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



Thanks guys for all your help, it turned out to be an error on my behalf, so simple, yet i over looked it for weeks!

God i feel like a total muppet!

Basically the problem was here

<font color="#3366FF">
<b>Go To Page:</b>
<%
FOR i = i to ProdRS.PageCount
IF i <> cINT( pg ) THEN
%>
<a href="dvdhome.asp?cat=<%=prodRS( "product_category" )%>&pg=<%=i%>">

What i had done was put an 'i' instead of a '1'

Once again thanks for your help

*i'll go hang my head in shame"

Tom