oracle| Page | data | Show ONE, introduction
Paging is required to access a table with a large amount of data through a browser. ASP's paging display of database records can be achieved through the ADO object set Recordset object. The recordset has the following several properties for paging display:
PageSize: The number of records displayed per page.
PageCount: According to the user's set of pagesize and the total number of records in the table, the system automatically calculates total pages. 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).
Knowing that the recordset has these attributes, I'm sure everyone thinks it's easy to achieve a paging display of the record. First open the database and table, and then set a good pagesize and AbsolutePage, and finally the record data output to the browser, you can do. Admittedly, it's as simple as using Access or SQL Server as a database, because both databases support the properties that are used by the recordset for paging. Oracle databases provide better security than access or SQL Server, and performance is dominant in the case of large amounts of data, but Oracle does not support these paging properties. This article will introduce a method of using ASP to realize the paging of Oracle data records, which makes it easy and easy for Oracle users to realize the paging display of records.
Second, the realization process analysis
1, the establishment of data sources
Install the Oracle client software to create a DSN through the Microsoft ODBC for Oracle driver, such as: "Dsn=servername; Uid=user; Pwd=password ".
2, the establishment of data tables
The simple profile structure is as follows (table name is data):
DATA:NAME,VARCHAR2;TELEPHONE,NUMBER;EMAIL,VARCHAR2;
3. Program code Analysis (this only analyzes the record display program display.asp)
<title> Personal Data Sheet </title>
<%
sql = "SELECT * FROM Data"//sql statement, remove all data from the datasheet
The following establishes a database connection
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
If there's no record, quit.
If rs.eof Then
Response.End
End If
%>
The table headers are 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= "140" align= "center" > Number </td>
<TD width= "140" align= "center" > Name </td>
<TD width= "140" align= "Center" > Tel </td>
<TD width= "140" align= "center" >E-mail</td>
</tr>
<%
RECORDSPERPAGE=10//Set record number of 10 records per page
currentpagenumber=0//Set current page number to 0
Index=1//Set record number to 1
If the current page number argument is not empty, converts its type to a long integer and calls the parameter
If Request.QueryString ("Currentpagenumber") <> "" Then
CURRENTPAGENUMBER=CLNG (Request ("Currentpagenumber"))
End If
Because the default page number starts at 0, the parameter is reduced by 1
Currentpagenumber=currentpagenumber-1
The following calculates the total number of record bars
Totalrrecord=0
while (not rs.eof)
Rs.movenext
Totalrecord=totalrecord+1
Wend
The following calculates the total number of pages 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, then 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
The record pointer returns to the first record
Rs.movefirst
Below let the record pointer cross the losing