数据库读出所有字段分页的代码,请看代码。
<!--#include file="conn.asp"--><link href="css/style.css" rel="stylesheet" type="text/css">
<style>
body {
background-color:#FFFFFF;
}
.STYLE1 { color: #FFF000;
font-size: 16px;
}
.STYLE2 {color: #FF0FFF; font-size: 16px; font-weight: bold; }
</style>
<%
dim sql
sql="select * from 档案 order by 流水号 desc"
set rs=server.createObject("adodb.recordset")
rs.open sql,conn,1,1
rs.pageSize=5
dim pageNo
pageNo=cint(request.queryString("pageNo"))
if pageNo<1 or isnumeric(pageNo)=false then pageNO=1
if pageNo>rs.pageCount then pageNo=rs.pageCount
rs.absolutePage=pageNo
dim i
i=1
ReturnCol = Rs.fields.count '字段个数
%>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bgcolor="#C4D8ED">
<tr>
<%for j = 0 to ReturnCol - 1 %>
<th scope="col"><%=Rs.fields(j).name%></th>
<%next%>
</tr>
<%
do while not rs.eof and i<=rs.pageSize
Response.Write("<tr>" )
%>
<td><% =rs(0)%> <td><a href=news/show.asp?id=<% =rs(0)%> target="_blank"><% =rs(0)%></a>
<%
for j = 1 to ReturnCol - 1
Response.Write("<td>"&Rs(j)&"</td>" )
next
Response.Write("</tr>")
i=i+1
rs.moveNext
loop
%>
</table>
<div>
<table border=0>
<tr>
<td>
共<% =rs.recordCount%>条
当前页次:<% =pageNo%>/<% =rs.pageCount%>
共<% =rs.pageCount%>页
<% if pageno<=1 or rs.recordCount<=rs.pageSize then %>
首页|
<% else%>
<a href=news/?pageNo=1>首页</a>|
<% end if%>
<% if pageno<=1 or rs.recordCount<=rs.pageSize then %>
上一页|
<% else%>
<a href=news/?pageNo=<% =pageNo-1%> >上一页</a>|
<% end if%>
<% if pageno>=rs.pageCount then %>
下一页|
<% else%>
<a href=news/?pageNo=<% =pageNo+1%> >下一页</a>|
<% end if%>
<% if pageno>=rs.pageCount then %>
尾页|
<% else%>
<a href=news/?pageNo=<% =rs.pageCount%> >尾页</a>|
<% end if%>
<select name="jump" onchange="javascript:window.open('?pageNo='+ this.options[this.selectedIndex].value,'_self')">
<%
dim page
for page=1 to rs.pageCount
if page=cint(pageNo) then%>
<option value=<% =page%> selected ><% =page%> </option>
<%else%>
<option value=<% =page%> ><% =page%></option>
<%end if
next
%>
</select>
</td>
</tr>
</table>
</div>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>