Det du leder efter, kaldes Recordset paging og du kan se et eksempel herunder:
<%@ LANGUAGE=\"VBSCRIPT\" %>
<% \' Listing 17.1 Paging through a Recordset Part 1: Declaration
Option Explicit
Response.Expires = 0
%>
<!--#include file=\"adovbs.inc\"-->
<%
Const intPageSize = 10
Dim intCurrentPage, objConn, objRS, strQ
Dim intTotalPages, intI
\' Listing 17.2 Paging Part 2: Setting the Current Page Number
If Request.ServerVariables(\"CONTENT_LENGTH\") = 0 Then
intCurrentPage = 1
Else
intCurrentPage = CInt(Request.Form(\"CurrentPage\"))
Select Case Request.Form(\"Submit\")
Case \"Previous\"
intCurrentPage = intCurrentPage - 1
Case \"Next\"
intCurrentPage = intCurrentPage + 1
End Select
End If
\' Listing 17.3[em]Paging[md]Part 3: Preparing the Recordset for Paging
Set objConn = Server.CreateObject(\"ADODB.Connection\")
objConn.Open \"Data Source=Northwind;User ID=sa;Password=;\"
Set objRS = Server.CreateObject(\"ADODB.Recordset\")
objRS.CursorLocation = adUseClient
objRS.CursorType = adOpenStatic
objRS.CacheSize = intPageSize
\' Listing 17.4[em]Paging[md]Part 4: Opening the Recordset
strQ = \"SELECT Customers.CompanyName, Orders.OrderDate \"
strQ = strQ & \"FROM Orders INNER JOIN Customers ON \"
strQ = strQ & \"Orders.CustomerID = Customers.CustomerID \"
strQ = strQ & \"ORDER BY Orders.OrderDate, \"
strQ = strQ & \"Customers.CompanyName\"
objRS.Open strQ, objConn, , , adCmdText
\' Listing 17.5 Paging Part 5: Setting the Recordset cursor
objRS.PageSize = intPageSize
If Not(objRS.EOF) Then objRS.AbsolutePage = intCurrentPage
\' Listing 17.6 Paging Part 6: Sending Database Data
intTotalPages = objRS.PageCount
%>
<HTML><BODY>
<B>Customer: OrderDate</B><P>
<%
For intI = 1 to objRS.PageSize
Response.Write Server.HTMLEncode(objRS(\"CompanyName\") & \":\" & objRS(\"OrderDate\")) & \"<BR>\"
objRS.MoveNext
If objRS.EOF Then Exit For
Next
objRS.Close : objConn.Close
Set objRS = Nothing : Set objConn = Nothing
%>
<BR>
Page <%= intCurrentPage %> of <%= intTotalPages %><P>
<% \' Listing 17.7 Paging Part 7: Providing Web Form for Paging %>
<FORM ACTION=\"<%= Request.ServerVariables(\"SCRIPT_NAME\") %>\" METHOD=\"POST\">
<INPUT TYPE=\"Hidden\" NAME=\"CurrentPage\"
VALUE=\"<%= intCurrentPage%>\">
<%
If intCurrentPage > 1 Then %>
<INPUT TYPE=\"Submit\" NAME=\"Submit\" VALUE=\"Previous\">
<% End If
If intCurrentPage <> intTotalPages Then %>
<INPUT TYPE=\"Submit\" NAME=\"Submit\" VALUE=\"Next\">
<% End If %>
</FORM>
</BODY></HTML>
Du kan også kigge her:
http://www.activeserverpages.dk/aspdigital/kapitel2/paging.asp