Bu kod vardı ne gerekti diyebilirsiniz. getrows komutu ile veritabanından bir kere veri çekersiniz, ama for veya while döngüleri ile veritabanından irtibatınız işlem bitene kadar bitmez. Bu da performans açısından önemli bir durumdur.
Örnek :
<font face="Verdana" size="2" color="#0000FF"><b>Listelenen Kayıtlar :</b></font>
<%
id=request.querystring("id")
intPage = cInt(Request.QueryString("page"))
If (intPage = 0) or (intpage="") then
intPage = 1
end if
liste_say= 7
Set rs=Server.CreateObject("Adodb.Recordset")
Sorgu="Select * from topik where id="&id&" "
'On Error Resume Next
rs.Open Sorgu, bag, 1, 3
If rs.EOF Then
Response.write"İlgili Kayıta rastlanamadı"
response.end
Else
messagecount = rs.Recordcount
rs.PageSize = cint(liste_say)
rs.AbsolutePage = intPage
sayfa1= rs.PageCount
kayitlar = rs.GetRows(liste_say)
end if
rs.close
set rs=nothing
%>
<font face="Verdana" size="2"><%=sfysirala()%></font>
<table border="0" width="100%" style="border-style: solid; border-width: 1" bordercolor="#C0C0C0">
<%
i=1
for j=0 to Ubound(kayitlar,2)
if j<0 then exit for
baslik= kayitlar(5,j)
%>
<%if i mod 2 then
renk="F2F2F2"
else
renk="ffffff"
end if
%>
<tr>
<td width="3%" bgcolor="#<%=renk%>"><%response.write i%></td>
<td width="97%" bgcolor="#<%=renk%>" colspan="2"><%=baslik%></td>
</tr>
<%
i=i+1
next
%> <tr>
<td width="3%" bgcolor="#<%=renk%>">
</td>
<td width="24%" bgcolor="#<%=renk%>"><font face="Verdana" size="2"> <b>Toplam Kayıt:</b> <%=messagecount%> </font></td>
<td width="73%" bgcolor="#<%=renk%>"><font face="Verdana" size="2"><%=sfysirala()%></font> </td>
</tr>
</table>
Fonksiyonumuz : <%
Function sfysirala()
If (messagecount/ liste_say) <> Fix(messagecount/ liste_say) then
intposts = Fix(messagecount/ liste_say) + 1
else
intposts = (messagecount/ liste_say)
end if
if intPosts >= 1 then
Sayfa="Sayfa"
Response.Write "<br /><div style=""text-align=right;""><span class=""stort"">" & Sayfa & ": " & intPosts & " (</span>"
If intPage > 1 Then
Response.Write "<a href=""?page=1" & "&id=" & id& """> İlk Sayfa </a> ... "
Response.write "<a href=""?page=" & intPage-1 & "&id=" & id& """><<</a> "
End If
For i = intpage-4 to intpage+4
If i > intPosts Then Exit For
if i <> cint(intPage) Then
If i >= 1 Then
response.write "<a href=""?page=" & i &"&id=" & id& """>" & i & "</a> "
End If
else
response.write " <a href=""#"">[" & i & "]</a> "
end if
Next
If intPage + 1 =< intposts Then
Response.write "<a href=""?page=" & intPage+1 &"&id=" & id& """>>></a> "
Response.write " ... <a href=""?page=" & intPosts &"&id=" & id& """>Son Sayfa</a>"
End if
Response.Write "<span class=""stort"">)</span></div>"
end if
End Function
%>