codice:
<%

pageSize = 20

if(len(Request.QueryString("page"))=0)then
  currentPage = 1
else
  currentPage = CInt(Request.QueryString("page"))
end if

sql = "SELECT COUNT(*) AS CNT FROM tbl"
set rs = cn.execute(sql)

recordCount = rs("CNT")
pageCount = int(CInt(recordCount) / pageSize)
rs.Close()

ord = trim(request("ord"))
if ord = "" then
ord = "uoat"
end if

if codice <> "then
   
   sql = "SELECT * FROM tbl where codice = "&codice&" order by "& ord &" LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize 

else
  
   sql = "SELECT * FROM tbl order by "& ord &" LIMIT " & (currentPage - 1) * pageSize & ", " & pageSize

end if

set rs = server.createObject("ADODB.Recordset")
rs.open sql, cn, 1, 3

if rs.eof then

   response.write "Nessun record"

   else
      While Not rs.eof

' stampa i records estratti

  rs.MoveNext
      wend
end if

'Paginazione

Response.Write "Numero Pagine:
"
For page = 1 to pageCount
  Response.Write "<A href='"&istring&"?page="&page
  Response.Write "&codice="&codice
  Response.write "'>"
  Response.write "<font size=1 color=#000080>"
  Response.Write page
  Response.Write "</A> " 
Next
Response.Write ">>"

rs.close
cn.Close

set rs = nothing
set cn = Nothing

%>