Paging display of Oracle data record using ASP
I. Introduction
Paters are required when accessing data volumes through the browser. The ASP records the database record paging display can be implemented by the ADO object set Recordset object. Recordset has the following properties for paging display:
PageSize: The number of records shown per page.
PageCount: The system automatically calculates the total number of pages based on the total number of records in the Pagesize and tables set. RecordCount: The total number of records in the table.
AbsolutePage: Represents the current page number. If you set the AbsolutePage property to 3, then the current record moves to Article 1 (That is, Article 31).
After knowing that Recordset has these properties, I believe that everyone feels that the paging display of records is very simple. Turn on the database and table first, set PageSize and AbsolutePage, and finally the recorded data is output to the browser, you can do it. It is true that it is as simple as using Access or SQL Server as a database, because both databases support these few properties for paging of RecordSet. Compared to Access or SQL Server, the Oracle database provides better security, and performance is dominated in the case of large data volume, however Oracle does not support these paging properties. This article will introduce a method of implementing a paging paging to Oracle data using the ASP to enable Oracle users to easily implement recording paging display.
Second, realize process analysis
1, establish a data source
Install Oracle client software, establish DSN through the Microsoft Odbc for Oracle driver, such as "DSN = ServerName; UID = USER; PWD = Password".
2, establish a data sheet
Simple personal data sheet structure is as follows (Name DATA):
Data: Name, Varchar2; Televhone, Number; Email, Varchar2;
3, program code analysis (only in this analysis record display program display.asp)
hEAD>
<%
SQL = "SELECT * from a" // SQL statement, remove all data from the DATA table
// The following to establish 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 is no record, you will exit it.
IF r.eof then
Response.end
END IF
%>
// The following display head
Personal data
p>
number td> | Name td> | phone td> | e-mail td>
TR> <% Recordsperpage = 10 // Sets per page display record number 10 records CurrentPagenumber = 0 // Set the current page number 0 INDEX = 1 // Setup number 1 // If the current page number parameter is not empty, turn its type to a long integer, and call this parameter. If Request.QueryString ("CurrentPagenumber") <> "" " CurrentPagenumber = CLNG (Request ("CurrentPagenumber"))) END IF // Because the default page number starts from 0, the parameters should be reduced by 1 CurrentPagenumber = CURRENTPAGENUMBER-1 // The following calculation total record number TotalRrecord = 0 While (Not Rs.eof) Rs.movenext TotalRecord = TotalRecord 1 Wend // The following calculation total page 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, display the homepage IF currentpagenumber <0 THEN CurrentPagenumber = 0 END IF // If the input page number parameter is larger than the total number of pages, the last page is displayed. If CurrentPagenumber> (TotalPagenumber-1) THEN CurrentPagenumber = (TotalPagenumber-1) END IF // Record the pointer to the first record Rs.movefirst // The following allows the record pointer to the previous record before entering the page, walk 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 / / The following shows the table content of the current page While (NOT RS.EOF) and (Number <= RecordsperPage) %> |
<% " td> // number | <% response.write RS "Name")%> td> // Name | <% response.write rs ("telephone")%> td> // | <% response.write RS ("email")%> td> // email
TR> <% Rs.movenext INDEX = INDEX 1 // Number plus 1 Number = Number 1 // counter plus 1 Wend Rs.close %> TABLE> center> div> html> // The following form implements the page number navigation |