ASP RecordSet Paging

Okay,

I is there some restrictions to how you call an ASP Page using the recordset thing.

My pages are going to be 4 includes

Header
Main Content
Side
Footer

At the top it opens the DB Connection.
Header is all HTML, DHTML
Main Content Is going to use the Recordset
Side is using ASP to put coupons in
Footer is just Javascript

If i do the main content itself it works fine
if i do everything besides the main content it works fine
when i do both together it says server error 500

What am i doing wrong?

HELP…I suck at this ASP stuff…

if you want an idea of what the page is going to look like checkout http://www.dealspree.com/dealster8.asp
that page works because it just post the last 18 deals

but the recordset thingy seems to be messing something up!

Hello,

A little bit of code goes a long way in these forums. If you post the source of your page, I’d be happy to help you. Also, be a little clearer in your statement of the problem…where in the code specifically does it reach the record, etc.

Then we’ll be sure to help. Thanks! :slight_smile:

<%
Dim cnnSimple ’ ADO connection
Dim rstSimple
Dim strDBPath
Dim Count
strDBPath = Server.MapPath(“MYDATABASE.mdb”)
Set cnnSimple = Server.CreateObject(“ADODB.Connection”)
cnnSimple.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & strDBPath & “;”
%>
<%
Dim rs
Set rs = Server.CreateObject(“ADODB.RecordSet”)
%>
<%
Set rstSimple = cnnSimple.Execute(“SELECT * FROM deals WHERE List=True ORDER BY ID DESC”)
Set rstCoupon = cnnSimple.Execute(“SELECT CouponTBL.SiteName, CouponTBL.Description, CouponTBL.ID, CouponTBL.CouponCode, CouponTBL.Expires FROM CouponTBL WHERE List=True ORDER BY ID DESC”)
%>
<html>

<head>
</head>

<body bgcolor=“#78A4B8” marginwidth=“0” marginheight=“0” leftmargin=“0” topmargin=“0”>

<table border=“0” cellpadding=“0” cellspacing=“0” width=“770”>
<tr>
<td width=“600” valign=“top”>

  &lt;table border="0" cellpadding="0" cellspacing="0"&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;img src="images/blk.gif" width="594" height="1"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;img scr="images/s.gif" width="1" height="7"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td align="center"&gt;&lt;img src="images/dealsterlogo.gif" width="215" height="78"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;table border="0" cellpadding="0" cellspacing="0"&gt;
    &lt;tr&gt;
      &lt;td&gt;      &lt;%

Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1

Dim qString
%>

        &lt;%

Dim mypage, numpages, numrecs, pagesize

mypage = CInt( Request(“page”) )
If mypage=0 Then mypage=1

pagesize = CInt( Request(“recs”) )
If pagesize = 0 Then pagesize = 10 ’ If we aren’t given a value use 10

'Set rs = Server.CreateObject(“ADODB.RecordSet”)
rs.PageSize = pagesize
rs.CacheSize = pagesize
rs.CursorLocation = adUseClient

qString = “SELECT * FROM deals WHERE Archive=True ORDER BY ID DESC”
rs.Open qString, cnnSimple, adOpenForwardOnly, adLockReadOnly, adCmdText

numpages = rs.PageCount
numrecs = rs.RecordCount

If mypage > numpages Then mypage = numpages
If mypage < 1 Then mypage = 1

rs.AbsolutePage = mypage

Response.Write(“<P> <B>” & numrecs & " records found.</B>" )
Response.Write("<BR> Page " & mypage & " of " & numpages & “</P>”)

Response.Write(“<CENTER>”)

Dim i
For i=1 To pagesize
If NOT rs.EOF Then
Response.Write(rs(“headline”) & " | " & rs(“store”) & " <BR>")
rs.MoveNext
End If
Next

Response.Write(“<P>”)

Dim x, lb, ub
For x=1 To numpages
lb = (x-1) * pagesize + 1
ub = x * pagesize
If ub > numrecs Then ub = numrecs
If x <> mypage Then
Response.Write(“<A HREF=archivester.asp?page=” & x & “&recs=” & pagesize & “>” & lb & “-” & ub & “</A>”)
Else
Response.Write(lb & “-” & ub)
End If
If x <> numpages Then Response.Write(" | ")
Next

Response.Write(“</CENTER>”)

rs.Close
cnnSimple.Close
Set rs = Nothing
Set cnnSimple = Nothing

        %&gt;

        &lt;p&gt;&nbsp;&lt;/p&gt;
        &lt;form name="myform" method="post" action="archivester.asp"&gt;
          Show &lt;select name="recs" onchange="updateBoxes(myform)"&gt;
            &lt;option value="5"&gt;5
            &lt;option value="10"&gt;10
            &lt;option value="25"&gt;25
            &lt;option value="50"&gt;50
            &lt;option value="100"&gt;100
          &lt;/select&gt; records per page&lt;br&gt;
          Display page &lt;select name="page"&gt;
            &lt;option&gt;
            &lt;option&gt;
            &lt;option&gt;
            &lt;option&gt;
            &lt;option&gt;
            &lt;option&gt;
            &lt;option&gt;
            &lt;option&gt;
          &lt;/select&gt;&lt;br&gt;
          &lt;input type="submit" value="GO!"&gt;
        &lt;/form&gt;

<SCRIPT LANGUAGE=“JavaScript”>

NUM_RECORDS = <%=numrecs%>;

function updateBoxes(theFormObj)
{
var selectedRecs = theFormObj.recs.options[theFormObj.recs.selectedIndex].value;
var numpages = Math.ceil(NUM_RECORDS / selectedRecs);

var numOptions = theFormObj.page.length;

for(var i=0 ; i<numOptions ; i++) {
theFormObj.page.options[0] = null;
}

for(var j=0 ; j<numpages ; j++) {
theFormObj.page.options[j] = new Option(j+1,j+1);
}
theFormObj.page.selectedIndex = 0;
}

</SCRIPT>

<SCRIPT>
updateBoxes(document.myform);
</SCRIPT>

      &lt;/td&gt;
      &lt;!--Second Column--&gt;
        &lt;!--Recent Coupons--&gt;

        &lt;table border="0" cellpadding="0" cellspacing="0"&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;img src="images/s.gif" width="20" height="1" alt&gt;&lt;/td&gt;
            &lt;td background="images/l.gif" width="20"&gt;&lt;img src="images/s.gif" width="20" height="1" alt="0"&gt;&lt;/td&gt;
            &lt;td background="images/b.gif"&gt;&lt;font size="2" face="Arial, Helvetica, Sans-Serif" color="#ffffff"&gt;&lt;b&gt;Recent
              Coupons&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
            &lt;td background="images/r.gif" width="20"&gt;&lt;img src="images/s.gif" width="20" height="1" alt="0"&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
        &lt;table border="0" cellpadding="0" cellspacing="0" width="98.5%" bgcolor="#000000" align="center"&gt;
          &lt;tr&gt;
            &lt;td&gt;
              &lt;table border="0" cellpadding="3" cellspacing="1" width="100%"&gt;
                &lt;tr&gt;
                  &lt;td bgcolor="#ffffff"&gt;
                    &lt;table border="0" cellpadding="3" cellspacing="0" width="100%"&gt;
                      &lt;tr&gt;
                        &lt;td&gt;
                          &lt;%
Dim i
i = 0
                          %&gt;

                          &lt;%

Do While i<=30
%>

                          &lt;em&gt;&lt;%= rstCoupon.Fields("SiteName").Value %&gt;&lt;/em&gt;&lt;br&gt;
                          &lt;span class="det"&gt;&lt;%= rstCoupon.Fields("Description").Value %&gt;&lt;br&gt;
                          Exp:&nbsp;&lt;%= rstCoupon.Fields("Expires").Value %&gt;&lt;br&gt;
                          Use Code:&nbsp;&lt;a href="jumpcpn.asp?ID=&lt;%= rstCoupon.Fields("ID").Value %&gt;"&gt;&lt;%= rstCoupon.Fields("CouponCode").Value %&gt;&lt;/a&gt;&lt;/span&gt;
                          &lt;hr size="1" color="blue"&gt;

                          &lt;%

i=i+1
rstCoupon.MoveNext

Loop
%>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>

okay:

firstly, in your connection string, you don’t need the last semicolon, although i don’t think it hurts to have it.

Secondly, instead of executing your DB code the way you have it, i would dim a recordset object and a variable to hold a SQL Query. I would then define that SQL Query, an do a command such as the following:

<%rs.Open SQLString, cnnSimple%>

This has shown great speed improvements in ADO (not to mention fewer errors). I acutally got that code from an ADO book.

Other than that, the rest of your code looks fine. I will, however, refer this post to Shane and KYank (my ‘partners in crime’ on the ASP Forums :)). They should be able to help much more than I can.

Hope this post is of some use! Good luck! :slight_smile:

Hi,

Looking through you code I couldn’t find the problem either. I think that your code would be easier to read/debug if it was broken down into functions.

The example below uses the Northwind db and basically does what you’re after. The code includes script/functions to set up html select list for the selecting the page no. and the number of records per page and regular hyperlinks for each page.

If you look at the code you should be able to adapt it to your own db. If you’ve got any questions just ask.


<%@Language="VBScript"%>
<%
Option Explicit

'Global variables
Dim strDBConnString

strDBConnString = "DRIVER={Microsoft Access Driver (*.mdb)};"
strDBConnString = strDBConnString & "DBQ=" & Server.Mappath("Northwind.mdb") & ";"
strDBConnString = strDBConnString & "uid=;pwd=;"

SUB DisplayProducts()

Dim rsProducts
Dim connProducts
Dim sProductsSQL
Dim sSupplier
Dim sProductName
Dim sProductPrice
Dim sProductID
Dim sProductLink

	sProductsSQL = "SELECT TOP 5 Suppliers.CompanyName AS [Supplier], " & _
									"Products.ProductName AS [Product], " & _
									"Products.UnitPrice AS [Price], " & _
									"Products.ProductID " & _
									"FROM Suppliers, Products " & _
									"WHERE Suppliers.SupplierID = Products.SupplierID " & _
									"ORDER BY Products.ProductName"
	
	Set connProducts = Server.createObject("ADODB.Connection")
	connProducts.Open strDBConnString
		
	Set rsProducts = Server.CreateObject("ADODB.Recordset")
	rsProducts.ActiveConnection = connProducts
	rsProducts.Open sProductsSQL
	
	If Not rsProducts.EOF Then
			
			Response.Write "<table>" & vbCrLf
			
			'Write out data
			Do While Not rsProducts.EOF
				'Read the filed values into variables
				sSupplier = Trim(rsProducts.Fields(0).Value)
				sProductName = Trim(rsProducts.Fields(1).Value)
				sProductPrice = Trim(rsProducts.Fields(2).Value)
				sProductID = Trim(rsProducts.Fields(3).Value)
				'Build the link for current record
				sProductLink = "<a href=" & Chr(34) & "productpage.asp?id=" & _
												Server.URLEncode(sProductID) & Chr(34) & _
												">" & sProductName & "</a>"
				
				'Write the values out
				Response.Write "<tr><td>" & sSupplier & "</td></tr>" & vbCrLf
				Response.Write "<tr><td>" & sProductLink & "</td></tr>" & vbCrLf
				Response.Write "<tr><td>" & sProductPrice & "</td></tr>" & vbCrLf
				Response.Write "<tr><td><hr class=" & Chr(34) & "productseparator" & Chr(34) & " noshade></td></tr>" & vbCrLf
				
				rsProducts.MoveNext
			Loop
			Response.Write "</table>" & vbCrLf
			
		End If
		
		rsProducts.Close
		Set rsProducts = Nothing
		connProducts.Close
		Set connProducts = Nothing

END SUB

SUB DisplayCustomerDetails()

Dim rsCustomers
Dim connCustomers
Dim sSQL
Dim sCustID
Dim sFieldValue
Dim sFieldName
Dim i
Dim iRecsPerPage
Dim iPage
Dim iPageCount
Dim iRecordCount
Dim iPageSize
Dim iRecNumber
Dim iFieldNumber
Dim iStartRec
Dim iFinishRec
		
		
		If Request.QueryString("displayno") <> "" Then
			iRecsPerPage = Request.QueryString("displayno")
		ElseIf Request.Form("displayno") <> "" Then
			iRecsPerPage = Request.Form("displayno")
		Else
			iRecsPerPage = 5
		End If
		
		If Request.QueryString("page") <> "" Then
			iPage = Request.QueryString("page")
		ElseIf Request.Form("page") <> "" Then
			iPage = Request.Form("page")
		Else
			iPage = 1
		End If
		
		
		sSQL = "SELECT CompanyName AS [Company], "
		sSQL = sSQL & "ContactName AS [Contact name], "
		sSQL = sSQL & "Phone, "
		sSQL = sSQL & "Fax "
		sSQL = sSQL & "FROM Customers"
		
		Set connCustomers = Server.createObject("ADODB.Connection")
		connCustomers.Open strDBConnString
		
		Set rsCustomers = Server.CreateObject("ADODB.Recordset")

		
		' -- Set up CursorLocation and CursorType for Recordset Paging to work
		rsCustomers.CursorLocation = 3	'adUseClient
		rsCustomers.CursorType = 3		'adOpenStatic
		rsCustomers.ActiveConnection = connCustomers
		rsCustomers.Open sSQL
			
			
	
		' Set the PageSize, CacheSize, and populate the intPageCount and
		' intRecordCount variables.
		rsCustomers.PageSize = iRecsPerPage	
		' The cachesize property sets the number of records that will be cached
		' locally in memory.
		rsCustomers.CacheSize = rsCustomers.PageSize
		iPageCount = CInt(rsCustomers.PageCount)
		iRecordCount = CInt(rsCustomers.RecordCount)
		iPageSize = CInt(rsCustomers.PageSize)
		iRecNumber = 0
		iFieldNumber = CInt(rsCustomers.Fields.Count - 1)
		
				
		' Now you must double check to make sure that you are not before the
		' start or beyond end of the recordset.  If you are beyond the end,
		' set the current page equal to the last page of the recordset.
		' If you are before the start, set the current page equal to the start
		' of the recordset.
		If CInt(iPage) > CInt(iPageCount) Then iPage = iPageCount
		If CInt(iPage) <= 0 Then iPage = 1
		
		' Make sure that the recordset is not empty.  If it is not, then set
		' the AbsolutePage property and populate the intStart and the intFinish
		' variables.
		If iRecordCount = 0 Then
			Response.Write "<p>No customers to display</p>"
		Else
			rsCustomers.AbsolutePage = iPage
			iStartRec = rsCustomers.AbsolutePosition
			If CInt(iPage) = CInt(iPageCount) Then
				iFinishRec = iRecordCount
			Else
				iFinishRec = iStartRec + (rsCustomers.PageSize - 1)
			End if
			
			'Display customers
			If Not rsCustomers.EOF Then
				
				Call DisplayPageNavigation(iPage, iPageCount, iRecsPerPage)
				
				'Write out table heading
				Response.Write "<b>Customers</b>" & vbCrLf
				
				Response.Write "<table>" & vbCrLf
								
				'Write out data
				Do While Not rsCustomers.EOF And iRecNumber < iPageSize
					
					For i = 0 to (rsCustomers.Fields.Count - 1)
						sFieldName = Trim(rsCustomers.Fields(i).Name)
						sFieldValue = Trim(rsCustomers.Fields(i).Value)
									
						'Check field values for nulls or blanks
						If IsNull(sFieldValue) Then
							sFieldValue = ""
						End If
						
						If sFieldValue <> "" Then
							Response.Write "<tr>"
							Response.Write "<td width=200>" & sFieldName & ": </td>"
							Response.Write "<td>" & sFieldValue & "</td>"
							Response.Write "</tr>" & vbCrLf
						End If
					Next
					Response.Write "<tr><td>&nbsp;</td></tr>" & vbCrLf
					iRecNumber = iRecNumber + 1
					rsCustomers.MoveNext
				Loop
				Response.Write "</table>" & vbCrLf
				
			End If
		End If
		
			
		'Free resources
		rsCustomers.Close
		Set rsCustomers = Nothing
		connCustomers.Close
		Set connCustomers = Nothing
	
END SUB

Sub DisplayPageNavigation(iCurrentPage, iTotalNoPages, iNoRecsPerPage)

Dim sScriptName
Dim x
Dim sPageNo
Dim sNoRecsPerPage
Dim sQueryString
Dim sPageLink
	
	sScriptName = Request.ServerVariables("SCRIPT_NAME")
	
	Response.Write vbCrLf & "<!-- Start of navigation -->" & vbCrLf
	
	'Create tablke to hold page navigation
	Response.Write "<table width=" & Chr(34) & "100%" & Chr(34) & ">" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td align=" & Chr(34) & "right" & Chr(34) & ">"
		
	'Set up string to be used in page select list
	'Eg: "1,2,3,4,5"
	sPageNo = ""
	For x = 1 to iTotalNoPages
		sPageNo = sPageNo & x
		If x < iTotalNoPages Then
			sPageNo = sPageNo & ","
		End If
	Next
		
	
	'Set up string to be used in total records per page select list
	sNoRecsPerPage = "5,10,20,30,40"
		
	'Display form for page selection
	Response.Write "<form method=" & Chr(34) & "action=" & Chr(34) & sScriptName & Chr(34) & ">" & vbCrlf
	Response.Write "Records per page: "
	Call WriteSelect2(sNoRecsPerPage, "displayno", iNoRecsPerPage)
	Response.Write "Page: "
	Call WriteSelect2(sPageNo, "page", iCurrentPage)
	Response.Write "<input type=" & Chr(34) & "submit" & Chr(34) & "value=" & Chr(34) & "Submit" & Chr(34) & ">" & vbCrLf
	Response.Write "</form>" & vbCrLf
	
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td align=right>" & vbCrLf
	
	'Display hyperlink for every page number
	sQueryString = GetStrippedQueryString("page")
	For x = 1 to iTotalNoPages
		sPageLink = "<a href=" & Chr(34) & sScriptName & "?page=" & x & "&" & sQueryString & Chr(34) & ">" & x & "</a>" & vbCrLf
		Response.Write sPageLink & " "
	Next
	
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "</table>" & vbCrLf
	Response.Write vbCrLf & "<!-- End of navigation -->" & vbCrLf & vbCrLf

End Sub


SUB WriteSelect2(sValues, sSelectID, sSelectedValue)

Dim bValid
Dim sValue
Dim x
Dim arrValues
Dim iArraySize

	'Check input data
	If Len(sValues) > 0 Then
		
		arrValues = Split(sValues, ",", -1, 1)
		
		Response.Write "<select name=" & Chr(34) & sSelectID & Chr(34)
		Response.Write " id=" & Chr(34) & sSelectID & Chr(34) & ">" & vbCrLf
		
		iArraySize = UBOUND(arrValues,1)
		
		For x=0 to iArraySize
		
			bValid = True
			sValue = Trim(arrValues(x))
			
			'Check for nulls or blanks
			If IsNull(sValue) Then
				bValid = False
			ElseIf (sValue = "") Then
				bValid = False
			End If
			
			If bValid Then
				Response.Write "<option value=" & Chr(34) & sValue  & Chr(34)
				If sValue = sSelectedValue Then
					Response.Write " selected "
				End If
				Response.Write  ">" & sValue & "</option>" & vbCrLf
			End If
				
		Next
		Response.Write "</select>" & vbCrLf
	End If

END SUB

Function GetStrippedQueryString(sStripValue)
		
	Dim sPageAddress
	Dim sQueryString
	Dim iItemCount
	Dim i
		
		' -- Get the name of current page
		sPageAddress = (Request.servervariables("SCRIPT_NAME"))
				
		' -- Set up the querystring variables that are joined with the nav variable
		sQueryString = ""
				
		If Request.Form <> "" Then
			
			iItemCount = Request.Form.Count
			For i = 1 To iItemCount
				If (CStr(Request.Form.Key(i)) <> sStripValue) Then
					If i > 1 And (Len(sQueryString)>0) Then
						sQueryString = sQueryString & "&"
					End If
					sQueryString = sQueryString & Request.Form.Key(i) & "=" & Server.URLEncode(Trim(Request.Form(i)))
				End If
			Next
							
		ElseIf Request.QueryString <> "" Then
			
			iItemCount = Request.QueryString.Count
			For i = 1 To iItemCount
				If (CStr(Request.QueryString.Key(i)) <> sStripValue) Then
					If i > 1 And (Len(sQueryString)>0) Then
						sQueryString = sQueryString & "&"
					End If
					sQueryString = sQueryString & Request.QueryString.Key(i) & "=" & Server.URLEncode(Trim(Request.QueryString(i)))
				End If
			Next
							
		End If
		
		sQueryString = Replace(sQueryString, " ", "")
		GetStrippedQueryString =  sQueryString
		
	End Function

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Northwind Customer</title>
	<style>
	form {margin: 0px;}
	.productseparator {height: 1px; color: #3366cc}
	</style>
</head>

<body>
	<table>
	<tr>
		<td valign="top" width="500">
			<% Call DisplayCustomerDetails %>
		</td>
		<td valign="top">
			<% Call DisplayProducts %>
		</td>
	</tr>
	</table>
</body>
</html>

Shane

[FONT=century gothic][COLOR=royalblue]can someone help mi with my recordset paging??? i need to place a link in my page where i can view the next 10 pages of my website.

the first page will list all the first 10 pages of my recordset, which have 10 record in each page. so i want to display the next 10 pages when i click on a link Next, instead of page 11.[/COLOR]

please help mi…
[/FONT]

:bawling:

ive got a pageing script i can post if you want?

D’, try that. :smiley: should work, your stuff always seems to. If not, I’ll dig up something or revise the current one.

bhappy, what EXACTLY is it that you’re trying to page / do?

here is is then


<%
if isempty(request.querystring("PageNo")) then
	CurrPage = 1
else
	CurrPage = cint(request.querystring("PageNo"))
end if
Set RS = Server.CreateObject("ADODB.Recordset")
RS.CursorLocation = 3
RS.Open "SQL statement", connectString
RS.PageSize = 10 ' How many records per page you want
RS.AbsolutePage = CurrPage
DO UNTIL RS.AbsolutePage <> CurrPage OR RS.EOF
	' Write stuff to page
Loop

function getNext10(num)
	pageLen = len(num)
	if pageLen = 1 then
		next10 = 10
	elseif pageLen = 2 then
		pageRem = 10
		pageTen = right(num, 1)
		next10 = num + pageRem - pageTen
	elseif pageLen > 2 then
		pageRem = 10
		pageTen = right(num, 1)
		next10 = num + pageRem - pageTen
	end if
	getNext10 = next10
end function

function getPrev10(num)
	pageLen = len(num)
	if pageLen = 1 then
		prev10 = 1
	elseif pageLen = 2 then
		firstDig = left(num, 1)
		secondDig = right(num, 1)
		prev10 = num - secondDig - 10
	elseif pageLen > 2 then
		firstDig = right(num, 2)
		secondDig = right(num, 1)
		prev10 = num - secondDig - 10
	end if
	if prev10 = 0 then
		prev10 = 1
	end if
	getPrev10 = prev10
end function

RSPrevPage = CurrPage -1
RSNextPage = CurrPage + 1
next10 = getNext10(currPage)
prev10 = getPrev10(currPage)

if Next10 > RS.PageCount then
	next10 = RS.PageCount
end if

if prev10 = 1 AND next10 - 1 < 10 then
	start = 1
else
	start = Next10 - 10
if right(start, 1) > 0 then
	start = replace(start, right(start, 1), "0")
	start = start + 10
end if
end if

if RS.PageCount > 1 then
	if next10 > 10 then
		response.write("<p class=""para1""><a href=""" & request.servervariables("SCRIPT_NAME") & "?PageNo=" & Prev10 & """><<</a>   ")
	end if
	if not RSPrevPage = 0 then
		response.write("<a href=""" & request.servervariables("SCRIPT_NAME") & "?PageNo=" & RSPrevPage & """><</a>   ")
	end if
	for P = start to Next10
		if not P = CurrPage then
			response.write("<a href=""" & request.servervariables("SCRIPT_NAME") & "?PageNo=" & P & """>" & P & "</a> ")
		else
			response.write(" <b>" & P & " </b>")
		end if
	Next
	
	if not RSNextPage > RS.PageCount then
		response.write("<a href=""" & request.servervariables("SCRIPT_NAME") & "?PageNo=" & RSNextPage & """>></a>  ")
	end if
	if not Next10 = RS.PageCount then
		response.write("   <a href=""" & request.servervariables("SCRIPT_NAME") & "?PageNo=" & Next10 & """>>></a>")
	end if
end if
%>

:smiley:

Here is a pretty concise sample of how to do RecordSet paging without using up server resources: http://www.intelidev.com/demo/dbpage_better.txt
You can see it in action at http://www.intelidev.com/demo/dbsearch.asp