<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>View Few at a Time</TITLE>
</HEAD>
<BODY>
<%
Dim conn, rst, mySQL, currPage, rows, counter
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & _
        "c:\Learn_ASP_Classic\Northwind.mdb"
Set rst = Server.CreateObject("ADODB.Recordset")

rst.CursorType = 3 'adOpenStatic
rst.PageSize = 12

mySQL= "SELECT * FROM Customers ORDER BY CompanyName"
rst.Open mySQL, conn
If Request.QueryString("CurrPage")="" Then
    currPage=1
Else
    currPage=Request.QueryString("currPage")
End If

rst.AbsolutePage=currPage
rows = 0

Response.Write "<H2>Northwind Customers</H2>"
Response.Write "<I>Displaying page" & currPage & " of "
Response.Write rst.PageCount & "</I>"
Response.Write "<HR>"


Do While Not rst.EOF And rows < rst.PageSize
    Response.Write "<A HREF=""Address.asp?CustomerID=" & _
     rst("CustomerID") & """>"
     Response.Write rst("CompanyName") & "</A><BR>"
     rows = rows + 1
     rst.MoveNext
Loop

Response.Write "<HR>"
Response.Write "<B>Result Pages: </B>"

For counter = 1 To rst.PageCount
    Response.Write "<A HREF=""PageMe.asp?currPage=" & counter & """>"
    Response.Write counter & "</A>"
    Response.Write Chr(32)
Next
rst.close
Set rst = Nothing
conn.Close
Set conn = Nothing
%>
</BODY>
</HTML>

