您的位置:程序门 -> web 开发 -> asp



请高手指点一下我的分页代码哪个地方有误(asp+sql)


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请高手指点一下我的分页代码哪个地方有误(asp+sql)[已结贴,结贴人:kqogje]
发表于:2007-03-16 08:35:23 楼主
<table   width= "500 "   border= "0 "   cellpadding= "0 "   cellspacing= "0 "   class= "lantable ">
            <tr>
    <td   width= "20 "   height= "20 "   align= "center "   bgcolor= "#ebfaee "   class= "xialan "> id </td>
            <td   width= "100 "   align= "center "   class= "xialan "> 来自 </td>
            <td   width= "200 "   align= "center "   class= "xialan "> 标题   (点击查看并回复)   </td>
            <td   width= "110 "   align= "center "   class= "xialan "> 发送时间 </td>
            <td   width= "90 "   align= "center "   class= "xialan "> 操作 </td>
        </tr>
            <%
set   rs=server.createobject( "adodb.recordset ")
rs.open   "select   *   from   [ns_user]   where   username= ' "&session( "ns_username ")& " ' ",conn,1,1
user_id=rs( "id ")
rs.close
set   rs=server.createobject( "adodb.recordset ")
sql= "select   *   from   [ns_msg]   where   geter= "&user_id& "   order   by   id   desc "
rs.open   sql,conn,1,1
if   rs.recordcount=0   then
response.write   " <tr> <td   colspan=6   align=center   class=xialan   height=30> 暂无任何短信 </td> </tr> "
else  
page=request.querystring( "page ")
rs.pagesize=5
total=rs.recordcount

if   not   isempty(trim(request( "page ")))   then  
page   =   cint(request( "page "))        
        if   page> rs.pagecount   then  
rs.absolutepage   =   rs.pagecount                
elseif   page   <=   0   then  
page   =   1  
      else
              rs.absolutepage   =   page  
        end   if
end   if
page   =   rs.absolutepage
for   i=1   to   rs.pagesize
if   rs.eof   then
exit   for  
end   if  
%>
            <tr   onmouseover= "this.style.backgroundcolor= '#eeeeee ' "   onmouseout= "this.style.backgroundcolor= '#ffffff ' "   >
                <td   width= "20 "   align= "center "   bgcolor= "#ebfaee "   class= "xialan "> <%=i%> </td>
            <td   width= "100 "   align= "left "   class= "xialan "   height= "25 "> &nbsp; <%
set   rs1=server.createobject( "adodb.recordset ")
rs1.open   "select   *   from   [ns_user]   where   id= "&rs( "sender "),conn,1,1
response.write   rs1( "username ")
rs1.close
    %> </td>
            <td   width= "200 "   align= "left "   class= "xialan "> &nbsp; <a   href=ns_sms.asp?action=view&id= <%=rs( "id ")%> > <%=rs( "title ")%> </a> </td>
            <td   width= "110 "   align= "center "   class= "xialan "   > <%=rs( "sendtime ")%>         </td>
            <td   width= "90 "   align= "center "   class= "xialan "> <a   href= "ns_sms.asp?action=del&id= <%=rs( "id ")%> "> 删除 </a> </td>
                </tr>
            <%rs.movenext
next%>
            <tr> <td   height= "10 "   colspan= "5 "> <table   width= "100% "     border= "0 "   cellpadding= "0 "   cellspacing= "0 ">
                <tr>
<td   height= "20 "   align= "center ">
<%if   rs.pagecount <> 1   and   rs.pagecount <> 0   then%>
<%if   page <rs.pagecount   then%>
<%if   page=1   then   %>
[首页]   [上一页]
<%else%>
[ <a   href= "ns_sms.asp?page= <%=1%> "> 首页 </a> ]
[ <a   href= "ns_sms.asp?page= <%   =page-1   %> "> 上一页 </a> ]
<%   end   if   %>
[ <a   href= "ns_sms.asp?page= <%=page+1%> "> 下一页 </a> ]  
[ <a   href= "ns_sms.asp?page= <%=rs.pagecount%> "> 尾页 </a> ]
<%else%>
[ <a   href= "ns_sms.asp?page= <%   =   1%> "> 首页 </a> ]
[ <a   href= "ns_sms.asp?page= <%   =page   -1   %> "> 上一页 </a> ]
[下一页]   [尾页]
  <%end   if   %>
<%else%>
[首页]   [上一页]   [下一页]   [尾页]
<%end   if%>
[页次: <font   color=red> <b> <%=page%> </b> </font> / <%=rs.pagecount%> ]
[共 <%=rs.recordcount%> 条   <font   color=red> <b> <%=rs.pagesize%> </b> </font> 条/页]
    </td>
                </tr>
            </table> </td>
</tr>
        </table>
发表于:2007-03-16 08:55:121楼 得分:0
哪行报错?
发表于:2007-03-16 08:57:402楼 得分:0
没有错误,但就是上一页链接地址为-2,下一页链接地址为0,并且当前页为-1
发表于:2007-03-16 09:00:373楼 得分:20
rs.cursorlocation=3
rs.open   sql,conn,1,3

试试
发表于:2007-03-16 09:14:194楼 得分:0
好了,谢谢啊
为什么么啊
我以前用的是access,现在换成sql了,分页代码为什么不能用了?
发表于:2007-03-16 09:16:575楼 得分:0
1,1不支持什么游标的,好象
发表于:2007-03-16 09:20:256楼 得分:0
我的那个是在access下测试通过的
但换成sql为什么就必须得用1,3啊


快速检索

最新资讯
热门点击