Prova con questo:
codice:
<html>
<head>
<title>Paginazione</title>
</head>
<%
'============================= Imposto il numero dei record per pagina e il nome della pagina ================================================
Dim num, nome_pagina
num = 2
nome_pagina = "vetrina.asp"
'======================================================= FINE ================================================================================
' Connessione database
Set conn = Server.CreateObject("ADODB.Connection")
dsnpath = "DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)}; "
dsnpath = dsnpath & "DBQ=" & Server.MapPath("db/immobili.mdb")
conn.open dsnpath
%>
<body background="images/sfondo_linea_colonna.jpg" link="#000080" vlink="#000080" alink="#0000FF">
<div align="center">
<center>
<table cellpadding="4" width="100%" height="90" style="border-width:1px; border-collapse: collapse; ">
<tr>
<td width="57" bgcolor="#C0C0C0" height="29" style="border-right:1px solid #C0C0C0; border-bottom:1px solid #C0C0C0; border-top-width:1px">
<p align="left"><font face="Verdana" size="1" color="#FFFFFF">Codice</font></td>
<td width="150" bgcolor="#C0C0C0" height="29" style="border-left:1px solid #C0C0C0; border-right:1px solid #C0C0C0; border-bottom:1px solid #C0C0C0; border-top-width:1px">
<p align="left"><font face="Verdana" size="1" color="#FFFFFF">
Ubicazione</font></td>
<td width="173" bgcolor="#C0C0C0" height="29" style="border-left:1px solid #C0C0C0; border-right:1px solid #C0C0C0; border-bottom:1px solid #C0C0C0; border-top-width:1px" align="center">
<p align="left"><font face="Verdana" size="1" color="#FFFFFF">
Tipologia</font></td>
<td width="260" bgcolor="#C0C0C0" height="29" style="border-left:1px solid #C0C0C0; border-right:1px solid #C0C0C0; border-bottom:1px solid #C0C0C0; border-top-width:1px" align="center">
<font face="Verdana" size="1" color="#FFFFFF">Prezzo</font></td>
<td width="27" bgcolor="#C0C0C0" height="29" style="border-left:1px solid #C0C0C0; border-right:1px solid #C0C0C0; border-bottom:1px solid #C0C0C0; border-top-width:1px" align="center">
<font face="Verdana" size="1" color="#FFFFFF">Strutturato</font></td>
<td width="27" bgcolor="#C0C0C0" height="29" style="border-left:1px solid #C0C0C0; border-right:1px solid #C0C0C0; border-bottom:1px solid #C0C0C0; border-top-width:1px" align="center">
<font face="Verdana" size="1" color="#FFFFFF">Varie</font></td>
<td width="27" bgcolor="#C0C0C0" height="29" style="border-left:1px solid #C0C0C0; border-right:1px solid #C0C0C0; border-bottom:1px solid #C0C0C0; border-top-width:1px" align="center">
<font face="Verdana" size="1" color="#FFFFFF">Immagine</font></td>
</tr>
<%
SQL="SELECT * FROM immobili Order by 'pz' ASC"
Set rec = Server.CreateObject("ADODB.Recordset")
Set Rec=Conn.Execute(SQL)
'While Not rec.EOF%>
<%'=================================================== INIZIO PAGINAZIONE ====================================================== %>
<%
'************ IMPOSTAZIONE NOME PAGINA E NUMERO DI RECORD DA VISUALIZZARE PER PAGINA *************
RecPerPagina = num '# Indicare il numero di record che si voglio visualizzare in ogni pagina
NomPagina = nome_pagina '# Indicare la pagina dove è inserito questo script comprese le variabili da passare
VarPagina = "falso" '# Se oltre al nome della pagina sono state inserite variabili indicare "vero" altrimenti "falso"
'--------------------------
If VarPagina = "vero" then
VarPagina = "&"
Else
VarPagina = "?"
End If
'********************* CONTROLLO RECORD ***********************************************
If rec.EOF = true or rec.BOF = true then
response.write "<center><font face='Verdana' size='2'> "
Response.write "Nessun Record presente"
response.write "</font></center> "
Else
'********************* IMPOSTAZIONE NUMERO PAGINE *************************************
TotRecord = 0
Do While not rec.EOF
TotRecord = TotRecord + 1
rec.MoveNext
Loop
rec.MoveFirst
If TotRecord < RecPerPagina Then
Pagine = 1
Else
Pagine = TotRecord / RecPerPagina
End If
ArrPagine = Round(Pagine)
If Pagine > ArrPagine then
Pagine = ArrPagine + 1
Else
Pagine = ArrPagine
End If
'******************** IMPOSTAZIONE DELLA PAGINA CORRENTE *******************************
Pagina = Request("page")
If Pagina = "" Then Pagina = 1 End If
PrimoRecord = (Pagina * RecPerPagina) - (RecPerPagina - 1)
UltimoRecord = PrimoRecord + RecPerPagina
'********************* VISUALIZZAZIONE *************************************************
rec.Move(PrimoRecord - 1)
For Conteggio = 1 to RecPerPagina
If rec.Eof then
Conteggio = RecPerPagina
Else
%>
<%'================================================================================================================================ %>
<tr>
<td width="58" height="30" style="color: #000080; font-family: Verdana; font-size: 8 pt; border-bottom: 1px solid #C0C0C0; ; border-left-width:1px; border-right-width:1px; border-top-width:1px" valign="top">
<font size="1" face="Verdana"><%=rec("Pz")%></font></td>
<td width="151" height="30" style="color: #000080; font-family: Verdana; font-size: 8 pt; border-bottom: 1px solid #C0C0C0; ; border-left-width:1px; border-right-width:1px; border-top-width:1px" valign="top">
<font size="1" face="Verdana"><%=rec("Ubicazione")%></font></td>
<td width="174" height="30" style="color: #000080; font-family: Verdana; font-size: 8 pt; border-bottom: 1px solid #C0C0C0; ; border-left-width:1px; border-right-width:1px; border-top-width:1px" valign="top" align="center">
<%=rec("Tipologia")%></td>
<td width="261" height="30" style="color: #000080; font-family: Verdana; font-size: 8 pt; border-bottom: 1px solid #C0C0C0; ; border-left-width:1px; border-right-width:1px; border-top-width:1px" valign="top" align="center">
<%=rec("prezzo")%></td>
<td width="28" height="30" style="color: #000080; font-family: Verdana; font-size: 8 pt; border-bottom: 1px solid #C0C0C0; ; border-left-width:1px; border-right-width:1px; border-top-width:1px" valign="top" align="center">
<%=rec("strutturato")%></td>
<td width="28" height="30" style="color: #000080; font-family: Verdana; font-size: 8 pt; border-bottom: 1px solid #C0C0C0; ; border-left-width:1px; border-right-width:1px; border-top-width:1px" valign="top" align="center">
<%=rec("varie")%></td>
<td width="28" height="30" style="color: #000080; font-family: Verdana; font-size: 8 pt; border-bottom: 1px solid #C0C0C0; ; border-left-width:1px; border-right-width:1px; border-top-width:1px" align="center">
<a align="center" href="images/<%=rec("immagine")%>" rel="lightbox" title="<%=rec("immagine")%>">
[img]images/<%=rec([/img]" width="80"></a></td>
</tr>
<%'=================================================== FINE PAGINAZIONE ====================================================== %>
<%
rec.MoveNext
End If
Next
Response.write "
<center>"
'********************* pagine **************************************************
response.write "<font face='Verdana' size='1'>"
Response.write "Pagina n. " & Pagina & " di " & Pagine &" "
'********************* avanti **************************************************
'********************* INDICE PAGINE *******************************************
Indietro = Pagina - 1
Avanti = Pagina + 1
'********************* indietro ************************************************
If Pagina > 1 then
Response.write "<A HREF =" & "'" & NomPagina & VarPagina & "page=" & Indietro & "'" & ">" & "<span style='text-decoration: none'>" & "<" & " Indietro" & "</a>"
Response.write " - "
End If
%>
<%'********************************* parte che inserisce i numeri delle pagine *********************************************************************************%>
<%
'================================================ numeri pag ======================
page = request.queryString("page")
if len(page) = 0 or (not isNumeric(page)) then page = 1
if isNumeric(page) then page = cLng(page)
if page < 1 then page = 1
pageCount = pagine ' ovvero rs.pageCount
limitPage = 5 ' indica quanti numeri di pagina visualizzare
limitPage = int(limitPage)
if limitPage < 3 then limitPage = 3
if pageCount > limitPage then
if page > (limitPage - int(limitPage / 2)) then
iStart = page - int(limitPage / 2)
iEnd = page + int(limitPage / 2)
else
iStart = 1
iEnd = limitPage
end if
if iStart + limitPage > pageCount then iStart = pageCount - (limitPage - 1)
else
iStart = 1
iEnd = pageCount
end if
%>
<%
if page > (limitPage - int(limitPage / 2)) then
%>
<span style="text-decoration: none"><< Prima pagina</span>
-
<%
end if
%>
<%
for i = iStart to iEnd
if i = page then
%>
<%=i%>
<%
else
%>
<%=i%>
<%
end if
if i = pageCount then exit for
next
%>
<%
if iEnd < pageCount then
%> -
<span style="text-decoration: none">Ultima pagina >></span>
<%
end if
'================================================= FINE =============================
%>
<%'****************************** Fine parte che inserisce i numeri delle pagine *******************************************************************************%>
<%
If not rec.EOF then
Response.write " - " & "<A HREF =" & "'" & NomPagina & VarPagina & "page=" & Avanti & "'" & ">" & "<span style='text-decoration: none'>" & "Avanti" &">" & "</a>"
End If
End If
response.write "</font>"
response.write "</center>"
response.write "[b]<font face='Verdana' size='1'>
</font>"
%>
<%'================================================================================================================================ %>
</center>
</table>
</div>
</body>
</html>
Il file si chiama vetrina.asp. Il nome comunque lo puoi cambiare ma devi cambiarlo anche all'inizio dello script e cioè:
num = 2
nome_pagina = "vetrina.asp"
dove num = 2 è il numero dei recor per pagina (impostalo come vuoi)
e, come detto,
nome_pagina = "vetrina.asp" è il nome della pagina.
Volendo fare un lavoro più pulito potresti mettere tutta la parte "Inizio paginazione" in un file da includere e la stessa cosa puoi fare con "Fine paginazione".
Vedi se funziona