我的access数据库查询结果需要分页显示,但是执行结果没有显示,请教高手如何实现,谢谢!!
<!--#include file= "conn.asp "-->
<% jino=trim(request.form( "jino "))
teachername=trim(request.form( "teachername "))
exec= "select * from 课程 where jino= ' "+jino+ " ' and teachername= ' "+teachername+ " ' "
set rs=server.createobject( "adodb.recordset ")
rs.open exec,conn,1,1
if rs.eof then
response.write "请重新查询 "
response.end
end if
rs.PageSize=10 '##设置一个页码里面显示的记录数
pagecount=rs.PageCount '##pagecount是记录的个数
page=int(request.QueryString ( "page "))
if page <=0 then page=1
if request.QueryString( "page ")= " " then '##当前页为 page页
page=1
end if
rs.AbsolutePage=page
%>
<html>
<head>
<title> 查询结果 </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<script language= "JavaScript ">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName== "Netscape ")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW ¦ ¦ innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>
<body background= "images/bg1.jpg " bgcolor= "#FFFFFF " text= "#000000 " >
<div align= "center ">
<p> <font color= "#660033 "> <font size= "4 " color= "#000000 "> 2007年 <font color= "#FF0000 "> </font> </font> </font> <br> </p>
</div>
<div align= "center ">
<tr background= "images/bg1.jpg ">
<td height= "16 " width= "40 " background= "images/bg1.jpg ">
<div align= "center "> <b> <font color= "#000000 "> 日期 </font> </b> </div>
</td>
<td height= "16 " width= "40 ">
<div align= "center "> <b> <font color= "#000000 "> 星期 </font> </b> </div>
</td>
<td height= "16 " width= "40 ">
<div align= "center "> <b> <font color= "#000000 "> 课节 </font> </b> </div>
</td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td width= "40 " height= "11 "> <div align= "center "> <%=rs( "teachdate ")%> </div> </td>
<td width= "40 " height= "11 "> <div align= "center "> <%=rs( "week ")%> </div> </td>
<td width= "40 " height= "11 "> <div align= "center "> <%=rs( "jieci ")%> </div> </td>
</tr>
<%
rs.movenext
loop
%>
</table>
</div>
</table>
</center>
</div>
</body>
</html>
[解决办法]
<!--#include file= "conn.asp "-->
<% jino=trim(request.form( "jino "))
teachername=trim(request.form( "teachername "))
exec= "select * from 课程 where jino= ' "+jino+ " ' and teachername= ' "+teachername+ " ' "
set rs=server.createobject( "adodb.recordset ")
rs.open exec,conn,1,1
if rs.eof then
response.write "请重新查询 "
response.end
end if
rs.pagesize=20
PageNo=request( "PageNo ")
if request( "PageNo ")= " " then PageNo=1
totalpages=rs.pagecount
if request.servervariables( "content_length ") > 0 then
currentpage=1
else
currentpage=clng(PageNo)
end if
if currentpage> totalpages then currentpage=totalpages
if not(rs.eof) then rs.absolutepage = currentpage
%>
<html>
<head>
<title> 查询结果 </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<script language= "JavaScript ">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName== "Netscape ")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW ¦ ¦ innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>
<body background= "images/bg1.jpg " bgcolor= "#FFFFFF " text= "#000000 " >
<div align= "center ">
<p> <font color= "#660033 "> <font size= "4 " color= "#000000 "> 2007年 <font color= "#FF0000 "> </font> </font> </font> <br> </p>
</div>
<div align= "center ">
<table>
<tr background= "images/bg1.jpg ">
<td height= "16 " width= "40 " background= "images/bg1.jpg ">
<div align= "center "> <b> <font color= "#000000 "> 日期 </font> </b> </div>
</td>
<td height= "16 " width= "40 ">
<div align= "center "> <b> <font color= "#000000 "> 星期 </font> </b> </div>
</td>
<td height= "16 " width= "40 ">
<div align= "center "> <b> <font color= "#000000 "> 课节 </font> </b> </div>
</td>
</tr>
<%
rowcount=(currentpage - 1)*rs.pagesize
for i=1 to rs.pagesize
if rs.eof then exit for
%>
<tr>
<td width= "40 " height= "11 "> <div align= "center "> <%=rs( "teachdate ")%> </div> </td>
<td width= "40 " height= "11 "> <div align= "center "> <%=rs( "week ")%> </div> </td>
<td width= "40 " height= "11 "> <div align= "center "> <%=rs( "jieci ")%> </div> </td>
</tr>
<%
rs.movenext
next
%>
</table>
<table width= "98% " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td height= "20 ">
<div align= "center ">
<%if currentpage> 1 then%>
<a href= "?pageno=1 "> 〖首页〗 </a> <a href= "?pageno= <%=currentpage-1%> "> 〖上一页〗 </a>
<%end if
if currentpage < totalpages then%>
<a href= "?pageno= <%=currentpage+1%> "> 〖下一页〗 </a> <a href= "?pageno= <%=totalpages%> "> 〖尾页〗 </a>
<%end if%>
本页是第 <%=currentpage%> / <%=totalpages%> 页 共 <%=rs.recordcount%> 条
转到第
<select name= "sel_page " onChange= "javascript:location=this.options[this.selectedIndex].value; ">
<%
for i = 1 to rs.PageCount
if i = currentpage then%>
<option value= "?pageno= <%=i%> " selected> <%=i%> </option>
<%else%>
<option value= "?pageno= <%=i%> "> <%=i%> </option>
<%
end if
next
%>
</select> 页
</div>
</td>
</tr>
</table>
</div>
</table>
</center>
</div>
</body>
</html>