[Turn]asp+oracle pagination

Source: Internet
Author: User

 
pagesize: The number of records displayed per page.
pagecount: The total number of pages is automatically calculated based on the user-defined pagesize and total records in the table.
recordcount: The total number of records in the table.
absolutepage: Represents the current page number. If you set the AbsolutePage property to 3, the current record moves to page 3rd 1th (that is, 31st).
  

first open the database and the table, then set the PageSize and AbsolutePage, and finally the record data output to the browser, you can be finished.
Admittedly, when you use Access or SQL Server as a database, it's as simple as both of these databases support the various properties of the recordset that are used for paging.
Oracle database provides better security compared to access or SQL Server, and performance is superior in the case of large amounts of data,
Span style= "FONT-SIZE:16PX;" However, Oracle does not support these paging properties. This article introduces a method of using ASP to display pagination for Oracle data records,

<%
sql = "SELECT * FROM Data"
Set conn = Server.CreateObject ("ADODB. Connection ")
Cnn.open "Dsn=servername;uid=user;pwd=password;"
Set Rs = Server.CreateObject ("ADODB". Recordset ")
Rs.cursortype = 3
Rs.locktype = 3
Rs.Open SQL, conn//exit if there is no record
If Rs.eof Then
Response.End
End If
%>

the table header is shown below//
<p align= "center" > Personal Data Sheet <br></p>
<div align= "center" >
<center>
<table border= "1" width= "560" cellspacing= "0" cellpadding= "0" >
<tr>
<td width= "" align= "center" > Numbering </td>
<td width= "" align= "center" > Name </td>
<td width= "align=" center > Phone </td> <td width= "align=" and "Center" >E-mail</td>
</tr>
<%
recordsperpage=10//Set the number of records to display per page 10 records
currentpagenumber=0//Set the current page number to 0
index=1//Set record number is 1
//If the current page number parameter is not empty, convert its type to a long integer and call the parameter
if Request.QueryString ("Currentpagenumber") <> "Then
currentpagenumber=clng (Request ("Currentpagenumber"))
End If
//Because the default page number starts at 0, subtract 1 from the parameter
currentpagenumber=currentpagenumber-1
The total number of records is calculated below//
totalrrecord=0
While (not rs.eof)
Rs.movenext
Totalrecord=totalrecord 1
Wend
the total number of pages is calculated Totalpagenumber
if (totalrecord mod recordsperpage) =0 Then
totalpagenumber= (totalrecord/recordsperpage)
Else
totalpagenumber= ((totalrecord/recordsperpage) 1)
End If
//If the input page number parameter is less than 0, the homepage is displayed
If currentpagenumber<0 Then
currentpagenumber=0
End If
//If the input page number parameter is greater than the total pages minus 1, the last page is displayed
if Currentpagenumber> (TotalPageNumber-1) Then
currentpagenumber= (TotalPageNumber-1)
End If
rs.movefirst//record pointer returns to first record
let the record pointer pass past the previous record of the input page number and go to the first record of the current page
Passnumber = Currentpagenumber*recordsperpage
For i=0 to PASSNUMBER-1
Rs.movenext
Next
INDEX = passnumber 1
Number = 1//number is the counter
//below displays the contents of the table for the current page
While (not rs.eof) and (number <= recordsperpage)
%>
<tr>
<td width= "" align= "center" ><%response.write (INDEX)%></td>//numbering
<td width= "" align= "center" ><%response.write Rs ("name")%></td>//Name
<td width= "" align= "center" ><%response.write Rs ("telephone")%></td>/Telephone
<td width= "" align= "center" ><%response.write Rs ("email")%></td>//e-mail
</tr>
<%
Rs.movenext
index = index 1//number plus 1
Number = number 1//Counter plus 1
Wend
Rs.close
%>
</table>
</center>
</div>

//The following form implements page numbering navigation
<% pagename= "display.asp"%>
<form action=<%= pagename%> method=get>
<%
If currentpagenumber<>0 Then
%>
<a href=<%= pagename%>? Currentpagenumber=1> first page </A>
<a href=<%= pagename%>? currentpagenumber=<%= (currentpagenumber)%>> prev </A>
<%
End If
If currentpagenumber<> (TotalPageNumber-1) Then
%>
<a href=<%= pagename%>? currentpagenumber=<%= (Currentpagenumber 2)%>> next </A>
<a href=<%= pagename%>? currentpagenumber=<%= (totalpagenumber)%>> last page </A>
<%
End If
%>
Enter page number: <input Type=text name=currentpagenumber> is now in the <%= (currentpagenumber 1)%> page/Total <%= Totalpagenumber%> page

[Turn]asp+oracle pagination

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.