asp查询数据分页,不成功

lukelukelukelukeluke 2015-02-26 07:15:56
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<html>
<head>
<link rel=stylesheet type=text/css href=asp.css>
</head>
<body>

<table align="center" border="0">
<tr>
<td><!--#include file="top.asp"--></td>
</tr>
</table>
<table align="center" border="0">
<form method="post" action="ckcx.asp"name="form1">
<tr>
<td colspan="8" align="center" bgcolor="#609B95"><strong>出 库 信 息 查 询</strong></td>
</tr>
<tr>
<td width="100"><div align="center">编号</div></td>
<td width="100"><div align="center">出库编号</div></td>
<td width="100"><div align="center">材料名称</div></td>
</tr>
<tr>
<td><input name="bh" class="wzjz" type="text" size="12" onFocus="this.value=''"></td>
<td><input name="ckbh" class="wzjz" type="text" size="12" onFocus="this.value=''"></td>
<td><input name="clmc" class="wzjz" type="text" size="12" onFocus="this.value=''"></td>
<td><input type="submit" name="ckc" value="查"></td>
</tr>
</form>
</table>
<%
if request("ckc")="查" then
if request("bh")<>""then
if cond="" then
cond="编号 like '%" & trim(request("bh")) & "%'"
else
cond = cond & " AND 编号 like '%" & trim(request("bh")) & "%'"
end if
end if
if request("ckbh")<>""then
if cond="" then
cond="出库编号 like '%" & trim(request("ckbh")) & "%'"
else
cond = cond & " AND 出库编号 like '%" & trim(request("ckbh")) & "%'"
end if
end if
if request("clmc")<>"" then
If cond="" Then
cond="材料名称 like '%" & trim(request("clmc")) & "%'"
else
cond = cond & "and 材料名称 like '%" & trim(request("clmc")) & "%'"
end if
end if
if cond<>""then
sql="select * from 出库表 where " & cond & "order by 日期"
else
sql="select * from 出库表 order by 日期"
end if
session("sql")=(sql)
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
response.write "<table border='1' align='center' cellpadding='1' cellspacing='1'>"
response.write "<tr>"
response.write "<th>编号</th> <th>出库编号</th> <th>日期</th> <th>材料名称</th> <th colspan='2'><a href='dc1.asp'>导出查询数据</a></th>"
response.write "</tr>"
%>
<tr><td colspan="12" class="wzjz">共有记录<%=rs.recordcount%>条</td></tr>
<%
do while not rs.eof
%>
<tr onMouseOver="this.bgColor='#99ccff'" onMouseOut="this.bgColor=''">
<td><input type="text" name="bh" class="xswb" readonly="true" size="12" value=<%=rs("编号")%>></td>
<td><input type="text" name="rkbh" class="xswb" readonly="true" size="10" value=<%=rs("出库编号")%>></td>
<td><input type="text" name="rq" class="xswb" readonly="true" size="10" value=<%=rs("日期")%>></td>
<td><input type="text" name="clmc" class="xswb" readonly="true" size="12" value=<%=rs("材料名称")%>></td>
<td class="wzjz" height="22" width=50><a href="ckxx.asp?id=<%=rs("id")%>" target="_blank">详细</a></td>
<td class="wzjz" height="22" width=50><a href="ckxg.asp?id=<%=rs("id")%>">修改</a></td>
<td class="wzjz" height="22" width=50><a onClick="return confirm('你确定要删除此记录吗?')" href="cksc_q.asp?id=<%=rs("id")%>">删除</a></td>
</tr>
<%
rs.MoveNext
loop
rs.Close
%>
</table>
<% end if %>
<body>
</html>

请哪位高手帮忙在以上代码中加一个带页码跳转历能的查询分页代码(带"1" "2" "3"…… 页码的链接跳转和带页码的下拉菜单跳转) 请在原代码上添加
非常感谢
...全文
127 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
csdn_aspnet 2015-02-27
  • 打赏
  • 举报
回复
<!-- #i nclude file="../conn.asp" -->    //(Yoko:路径按自己的设置好)
<%
dim i,intPage,page,pre,last,filepath
  set rs = server.CreateObject("adodb.recordset")
   sql="select * from user order by user_ID desc"
      rs.PageSize = 20         //(Yoko:这里设定每页显示的记录数
      rs.CursorLocation = 3
      rs.Open sql,conn,0,2,1   //(Yoko:'这里执行你查询SQL并获得结果记录集
      pre = true
      last = true
      page = trim(Request.QueryString("page"))
      
      if len(page) = 0 then
                  intpage = 1
                  pre = false
      else
          if cint(page) =< 1 then
               intpage = 1
               pre = false
          else
              if cint(page) >= rs.PageCount then
                  intpage = rs.PageCount
                  last = false
              else
                   intpage = cint(page)
             end if
         end if
      end if
    if not rs.eof then
         rs.AbsolutePage = intpage
    end if
%>
<!--循环开始-->
 <%    
   for i=1 to rs.PageSize
     if rs.EOF or rs.BOF then exit for
  %>
      ..................
     //(Yoko:要循环显示的内容  )..................
      ...................
   <%  
     rs.movenext
    next
   %>
<!--循环体结束
分页部分:-->
 <table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
   <tr>
     <%if rs.pagecount > 0 then%>
     <td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
     <%else%>
    <td width="41%" align="left">当前页0/0</td><%end if%>
    <td width="46%" align="right"> <a href="本页.asp?page=1">首页</a>| 
     <%if pre then%>
     <a href="本页.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
     <%if last then%>
      <a href="本页.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
      <a href="本页.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
      <select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
      <%
       for i = 1 to rs.PageCount
       if i = intpage then%>
       <option value="本页.asp?page=<%=i%>" selected><%=i%></option>
     <%else%>
       <option value="本页.asp?page=<%=i%>"><%=i%></option>
        <%
          end if
        next
        %>
     </select>页</font> 
    </td>
    </tr>
   </table>
xcgh 2015-02-27
  • 打赏
  • 举报
回复
希望给出是什么数据库,如mysql,sqlserver或oracle
itzhiren 2015-02-27
  • 打赏
  • 举报
回复
网上搜一下,有很多啊

28,376

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧