Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Paging technique

To use paging for the visualization of database records.


<%
RecordsPerPage = 5
page = Request("page")
if page="" then page=1
' SQL
strSearch = Request("search")
SQL = "SELECT * FROM [myTable] WHERE [myField] LIKE '%" & strSearch & "%'"
' paging
rs.PageSize = RecordsPerPage
rs.AbsolutePage = page
If rs.Eof=True or rs.Bof=True then
  Response.Write "<P>No results</P>"
Else
  For i=1 to RecordsPerPage
    if Not rs.EOF then
      'shows the record
      rs.MoveNext
    end if
  Next
End if
%>
To add a navigation bar:
<%
Response.Write "<P><B>Pages:</B> "
For pag=1 to rs.PageCount
Response.Write "<A href='pagina.asp?page=" & pag
Response.Write "&" & Server.UrlEncode(strSearch)
Response.write "'>"
Response.Write pag
Response.Write "</A> "
Next
Response.Write "</P>"
%>


Download code...


Print this page


 

Inizio pagina

risorse per webmaster