日期:2014-05-17  浏览次数:20684 次

分页中遇到的问题,代码如下:
<%  
call   conndb(conn)
set   rs=server.createobject( "adodb.recordset ")
sql= "select   *   from   ToolCabinets_Detail       order   by   id "
rs.open   sql,conn,1,1
%>

<%
page=1   '   设置变量PAGE=1  
rs.PageSize   =   16   '每页显示记录数  
if   Not   IsEmpty(Request( "Page "))   then   '如果PAGE已经初始化...  
Page   =   CInt(Request( "Page "))   '接收PAGE并化为数字型赋给PAGE变量  
if   Page   >   rs.PageCount   then   '如果接收的页数大于总页数  
rs.AbsolutePage   =   rs.PageCount   '设置当前显示页等于最后页  
elseif   Page   <=   0   then   '如果page小于等于0  
Page   =   1   '设置PAGE等于第一页  
else  
rs.AbsolutePage   =   Page   '如果大于零,显示当前页等于接收的页数  
end   if  
End   if  
intCurPage   =   rs.AbsolutePage  
%>  
<%  
For   i   =   1   to   rs.PageSize  
if   rs.eOF   then  
Exit   For  
end   if   '利用for   next   循环依次读出记录  
%>  
<%
do   while     not   rs.eof    
%>
<div   class= "table5 "> <a   href= "shows_ToolCabinets_Detail.asp?chname= <%=rs( "chname ")%> &amp;id= <%=rs( "id ")%> "   target= "_blank "> <img   src= " <%=rs( "shuomingurl ")%> <%=rs( "minpic ")%> "> </a>
</div>
<%
rs.movenext
loop
next
%>
</div>
<div   class= "table1 ">  
<%  
if   page <> 1   then%>  
<a   Href= "?Page= <%   =   1%> "> 首页 </a>  
<a   Href= "?Page= <%   =Page   -1   %> "> 上一页 </a>  
 
<%  
end   if   %>  
<%  
if   page <> rs.pagecount   then   %>  
<a   Href= "?Page= <%   =Page   +   1%> "> 下一页 </a>   <a   Href= "?Page= <%   =   rs.PageCount%> "> 尾页 </a>  
<%  
end   if
%>  
问题描述:
分页显示中,第一页显示全部数据,第二页显示除前16天记录之后的所有数据,以此类推,直到最后一页,显示才没问题。
帮忙找找原因吧?我奉送全部分数

------解决方案--------------------
do while not rs.eof
%>
<div class= "table5 "> <a href= "shows_ToolCabinets_Detail.asp?chname= <%=rs( "chname ")%> &amp;id= <%=rs( "id ")%> " target= "_blank "> <img src= " <%=rs( "shuomingurl ")%> <%=rs( "minpic ")%> "> </a>
</div>
<%
rs.movenext
loop

这个循环会把所有数据都列出来的。所以,有了for 就应该不要do while not ... loop这段了。