| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 522 人关注过本帖
标题:关于查询结果的分页问题
只看楼主 加入收藏
javaxingxing
Rank: 2
等 级:论坛游民
帖 子:78
专家分:82
注 册:2009-11-6
结帖率:93.33%
收藏
已结贴  问题点数:20 回复次数:4 
关于查询结果的分页问题
我看了看以前的相关帖子,不过没有找到答案,只有在这贴出来问问各位朋友了。
我的问题是,查询出结果并用分页显示,当查询完显示的时候,第一页是正常的,点击下一页就不行了,显示
Script error detected at line 14.
Source line: rs.Open sql,con,1,1
Description: ODBC 驱动程序不支持所需的属性
不清楚怎么回事,还是在分页的地方要传个什么值啊,我把部分代码贴出来,大家帮忙看看吧(ASP+access数据库)。
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../connections/ggcon.asp" -->
<% If session("login")=1 Then %>
<%
set rs = Server.CreateObject("ADODB.Recordset")
searchword=request.Form("searchword")
aform=request.Form("class")
sql = "SELECT  * FROM message where class="&aform&" order by id desc"
rs.Open sql,con,1,1
%>

<%
intPage=trim(Request.queryString("page"))
if intPage="" then
    intPage=1
elseif not isNumeric(intPage) then
    intPage="0"
elseif intPage>2147483647 or intPage<0 then
    intPage="0"
else
    intPage=cint(intPage)
end if
if intPage="0" then
    intPage=1
end if
%>

<style type="text/css">
<!--
.STYLE1 {font-size: larger}
-->
</style>
<form method="post" action="listsearch.asp">'当前页就是listsearch.asp
             <div align="right">
               <select name="class">
             <%do while not lrs.eof %>
               <label>               
                 <option value="<%=lrs("id")%>"><%=lrs("class")%></option>
               </label>
              <%lrs.movenext
              loop
              lrs.close%>                  
               </select>

               <input type="submit" name="button" value="选择类别查询">
  </div>
</form>

<%
if not rs.EOF then

    dim strLocation
    strLocation="listsearch.asp?"

    rs.PageSize=6
        
    intPagesize=rs.PageSize   
    intPagecount=rs.PageCount
    if intPage>intPagecount Then   
        intPage=intPagecount
    end if
   
    intRecordcount=rs.RecordCount
    intRecordStart=(intPage-1)*intPagesize+1   
    if intRecordStart+intPagesize-1>intRecordcount then
        intRecordEnd=intRecordcount
    else
        intRecordEnd=intRecordStart+intPagesize-1
    end if
   
    rs.AbsolutePosition=intRecordStart
%>

  <table width="899" height="62" border="1" align="center">
    <tr>
      <td width="128" align="center"><span class="STYLE1">类别</span></td>
      <td width="230" align="center"><span class="STYLE1">标题</span></td>
      <td width="341" align="center"><span class="STYLE1">添加日期</span></td>
      <td width="182" align="center"><span class="STYLE1">操作</span></td>
    </tr>
<%
    i=0
    do while not rs.EOF and i<intPagesize
%>
   
    <tr>
      <td><div align="center"><%=rs("class")%></div></td>
      <td><div align="center"><a href="message_look.asp?id=<%=rs("id")%>"><%=rs("title")%></div></td>
      <td><div align="center"><%=rs("adddate")%></div></td>
      <td><div align="center"><a href="message_edit.asp?id=<%=rs("id")%>">修改</a>&nbsp;&nbsp;            
                              <a href="message_del.asp?id=<%=rs("id")%>">删除</a></div></td>
    </tr>

<%
    rs.movenext
    i=i+1
loop
%>    </table>
  <br>
  <table border="0" width="620px" cellpadding="0" height="11" class="tx9pt" cellspacing="0">
    <tr>
      <td width="100%" height="5" align=right>
        <a href="<%=strLocation%>page=1" title="首页">首页</a>
        <%if intPage=1 then%>
        上一页
        <%else%>
        <a href="<%=strLocation%>page=<%=intPage-1%>" title="上一页">上一页</a>
        <%end if%>
         <%if intPage>=intPagecount then%>
        下一页
        <%else%>
        <a href="<%=strLocation%>page=<%=intPage+1%>" title="下一页">下一页</a>
        <%end if%>
        <a href="<%=strLocation%>page=<%=intPagecount%>" title="尾页">尾页</a>
      </td>
    </tr>
  </table>


    <%else%>
  <table width="620" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td align="center"><br>目前还没有记录!</td>
    </tr>
  </table><br>
</html>

<%
end if
rs.close
con.close
Set rs=nothing
set con=nothing
%>
<%
else
response.redirect "../index.asp"
end if
%>
搜索更多相关主题的帖子: 查询 结果 
2009-11-10 10:12
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:10 
aform没有传递
2009-11-10 11:08
javaxingxing
Rank: 2
等 级:论坛游民
帖 子:78
专家分:82
注 册:2009-11-6
收藏
得分:0 
<a href="<%=strLocation%>page=<%=intPage+1%>&class=<%=rs("class")%>" title="下一页">下一页</a>,然后我把上面的request.form改成request.querystring,
class传过来的是类别的id.这样不行啊,我都快崩溃了……

[ 本帖最后由 javaxingxing 于 2009-11-10 11:14 编辑 ]
2009-11-10 11:11
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:10 
<a href="<%=strLocation%>page=<%=intPage+1%>&class=<%=aform%>" title="下一页">下一页</a>,
然后把上面的request.form改成request
2009-11-10 11:26
javaxingxing
Rank: 2
等 级:论坛游民
帖 子:78
专家分:82
注 册:2009-11-6
收藏
得分:0 
回复 4楼 aspic
万分感谢,哎呀,问题终于解决了,太谢谢你了,就是按照你说的已修改就成功了,呵呵……
2009-11-10 11:31
快速回复:关于查询结果的分页问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019854 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved