I. jsp method:
**********************
<% @ Page Language = "Java" Import = "Java. util. *, java. SQL. *" %>
<% @ Page contenttype = "text/html; charset = gb2312" %>
<JSP: usebean id = "cn" Scope = "page" class = "myconnection. Conn"/> <! -- Reference the bean for database operations and complete it by yourself. I will not go into details here -->
<%
Int curpage = 1; // current page
Int page_record = 20; // number of records displayed on each page
// Use the following method (SQL query is completed, and the speed is fast)
Curpage = integer. parseint (request. getparameter ("page"); // obtain the passed value, the page to be displayed
Resultset rs = cn. rsexecutequery ("select top" + page_record + "* From tablename where id not in (select top" + (curpage * page_record) + "id from tablename order by id desc) order by id desc ");
// This query statement returns the 20 records on the 1000 page to be displayed. The general idea is that subqueries exclude all records before the records to be displayed, the parent query sorts the remaining records in descending order.
While (Rs. Next ){
Out. println (Rs. getint ("ID"). tostring ());
}
Rs. Close ();
%>
**********************
Ii. Methods in ASP
*******************
<% @ Language = "VBScript" codePage = "936" %>
<%
Dim curpage = 1' current page
Dim page_record = 20' number of records displayed per page
Curpage = request ("page") 'gets the passed value, the page to be displayed
...... 'The database connection operation code is omitted
Rs. open "select top" + page_record + "* From tablename where id not in (select top" + (curpage * page_record) + "id from tablename order by id desc) order by id desc ", Conn, 1, 3
'The query statement returns the 20 records on the 1000 page to be displayed. The general idea is that subqueries exclude all the records before the records to be displayed, the parent query sorts the remaining records in descending order.
While not Rs. EOF
Response. Write RS ("ID ")
Rs. movenext
Wend
Rs. Close
Conn. Close
%>
*********************
Thank you for reading this article. I hope this article will help you.