Salve, ho la seguente routine per fare la paginazione di un recordset
Sub Numerazione(iNumPerPage, sTable, sURL, sQuerystring)
Dim iTtlNumItems, iDBLoc, sSqlTemp, iTtlTemp
Dim iDBLocTemp, sURLBeg, iA, iB, x, iTemp, rsObj
iDBLoc = CInt(Request("iDBLoc"))
iTtlNumItems = CInt(Request("iTtlNumItems"))
' Get ttl num of items from the database if it's not already in the QueryString
if (iTtlNumItems = 0) then
Set rsObj = Server.CreateObject("ADODB.Recordset")
sSqlTemp = "SELECT COUNT(*) FROM " & sTable
rsObj.open sSqlTemp,conndb,1
If Not(rsObj.EOF) Then
iTtlNumItems = rsObj(0)
End If
rsObj.Close
Set rsObj = Nothing
end if
iTtlTemp = iTtlNumItems \ iNumPerPage ' this is the number of numbers overall (use the "\" to return int)
iDBLocTemp = iDBLoc \ iNumPerPage ' this is which number we are currently on (use the "\" to return int)
If (sQuerystring <> "") Then
sURLBeg = "<a href = """ & sURL & "?" & sQuerystring & "&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
Else
sURLBeg = "<a href = """ & sURL & "?iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
End If
'***** BEGIN DISPLAY *****
' Print the "Previous"
if (iDBLoc <> 0) then
Response.Write sURLBeg & (iDBLoc - iNumPerPage) & """>Previous</a> "
end if
' Print the <<
if (iDBLocTemp >= iNumPerPage) then
Response.Write sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage ^ 2) - (iNumPerPage * 9) & """><<</a> "
end if
' Print the numbers in between. Print them out in sets of 10.
iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
for x = iA to iB
iTemp = (x * iNumPerPage)
if (iTemp < iTtlNumItems) then ' takes care of extra numbers after the overall final number
if (iDBLoc = iTemp) then
Response.Write " [" & x+1 & "]"
else
Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1 & "</a>"
end if
else
exit for
end if
next
' Print the >>
if (iTtlTemp > iDBLocTemp) then
if ((iDBLocTemp + iNumPerPage) <= iTtlTemp) then
Response.Write " " & sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage ) * iNumPerPage & """>>></a> "
end if
end if
' Print the "Next"
if ((iDBLoc + iNumPerPage) < iTtlNumItems) then
Response.Write " " & sURLBeg & (iDBLoc + iNumPerPage) & """>Next</a>"
end if
'***** END DISPLAY *****
End Sub
che richiamo così
numero = 10
tabella = "news"
pagina = "news_ricerca.asp"
qq = ""
call Numerazione(numero,tabella,pagina,qq)
In corrispondenza della chiamata mi restituisce il seguente errore:
Errore di run-time di Microsoft VBScript (0x800A000D)
Tipo non corrispondente: 'Numerazione'
Bisogna definire i tipi??