| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1137 人关注过本帖
标题:asp组合查询分页问题,请教高手
只看楼主 加入收藏
qazqaz111
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-5-12
收藏
 问题点数:0 回复次数:12 
asp组合查询分页问题,请教高手
我是新手,遇到分页问题,请高手帮忙看看,参数传递不过去,点下一页显示全部
附源码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<!--#include file = "inc/conn.asp" -->
<!--#include file = "CheckLogin.asp" -->
<!--#include file = "inc/zhuru.asp" -->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<STYLE type=text/css>TD {
    FONT-SIZE: 9pt; LINE-HEIGHT: 12pt
}
A:link {
    COLOR: #0000ff; TEXT-DECORATION: none
}
A:visited {
    COLOR: #0000FF; TEXT-DECORATION: none
}
A:hover {
    COLOR: #CC6600; TEXT-DECORATION: underline
}
</STYLE></head>
<%
    Dim strSearchSql ,strKc ,strBy ,strBj ,strBy0,strxq
    strBy = Request("By")
    strBy0 = Request("By0")
    strBj = trim(Request("classid"))
    strKc = trim(Request("Kc"))
    strxq = trim(Request("xq"))
     bzr=Session("UserName")
        strSql = "SELECT * FROM class WHERE mainteacher='"&bzr&"'"
      Set rs11 = Server.CreateObject("ADODB.Recordset")
     rs11.open strSql,conn,1,1    
     bj=rs11("name")
    If strBj <> "" And  strBy <> "" and strKc <> "" and strby0 <> "" Then
        If strBy = "zp" and strby0 = "全部" Then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"'"
        elseIf strBy = "zp" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen > 59"
        elseIf strBy = "zp" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen < 60"
        elseIf strBy = "bukao1" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 > 59"
        elseIf strBy = "bukao1" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 < 60"
        elseIf strBy = "bukao2" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 > 59"
        elseIf strBy = "bukao2" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 < 60"
        elseIf strBy = "bukao3" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 > 59"
        elseIf strBy = "bukao3" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 < 60"


        Else
            strSearchSql = "WHERE "& strBy &" = '"& strBj &"' and kemu = '"& strKc &"'"
        End If    
    Else
        strSearchSql = "WHERE class = '"& bj &"'"

    End If
    Dim rs,rs11,rs22 ,strSql ,Num ,pageNum ,page ,loopNum
    bzr=Session("UserName")
    strSql = "SELECT * FROM Student_cj " & strSearchSql
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.open strSql,conn,1,1
        
    'If rs.EOF Then
    '    Response.Write("对不起,没有记录!")
    '    Response.End
    'End If

    
        
%>
<body topmargin="5" leftmargin="5">
<%
    If rs.recordcount > 0 Then
        rs.pagesize = 14
        Num = rs.recordcount
        pageNum = rs.pagecount
        page =  Request.QueryString("page")
        If page <> ""  Then
            page = Cint(page)
        ElseIf page < 1 Then
            page = 1
        Else
            page =1
        End If
        If page < 1 then
            page =1
        End If
        If page*rs.pagesize >Num and Not ((page-1)*rs.pagesize <Num) Then
            page = 1
        End If
        rs.absolutepage = page
        If page <> pageNum Then
            LoopNum = rs.pagesize
        Else
            LoopNum = Num - (page-1)*rs.pagesize
        End If
    
%>

<table width="808" style="border-collapse: collapse" height="37">
  <form id="form1" name="form1" id="form1" method="post" action="Index_Student_kq.asp" target="_self">
  <td width="796" bgcolor="#6699FF" height="37" align="center" colspan="16">
        选择班级:
          <select name="classid" size="1">
      <%
    strSql = "SELECT * FROM Class WHERE name='"&bj&"'"
    Set rs111 = Server.CreateObject("ADODB.Recordset")
    rs111.open strSql,conn,1,1
    %>
      <%
            Do While Not rs111.EOF
    %>
      <option value=<%=rs111("name")%> selected><%=rs111("name")%></option>
      <%
            rs111.movenext
            loop
            rs111.close
    %>
    </select>&nbsp;学期: <select name="xq" size="1">
          <option value=1 selected>第一学期</option>
     
             <option value="2">第二学期</option>
            <option value="3">第三学期</option>
            <option value="4">第四学期</option>
            <option value="5">第五学期</option>
     
         </select>
         
          科目:<select name="Kc" size="1">
    <%
    strSql = "SELECT * FROM suject"
    Set rs222 = Server.CreateObject("ADODB.Recordset")
    rs222.open strSql,conn,1,1
    %><%
            Do While Not rs222.EOF
    %>
      <option value="<%=rs222("name")%>" selected><%=rs222("name")%></option>
      <%
            rs222.movenext
            loop
            rs222.close
    %>

         </select>
          <select name="By" size="1">
            <option value="zp">总评成绩</option>
              <option value="bukao1">第一次补考</option>
            <option value="bukao2">第二次补考</option>
            <option value="bukao3">第三次补考</option>
          </select>
          <select name="By0" size="1">
            <option value="全部">全部</option>
            <option value="及格">及格</option>
              <option value="不及格">不及格</option>
          </select>
      <input type="submit" name="Submit" />
          </td>
   </form></table></table>
</td><table width="808" style="border-collapse: collapse" height="102">
  <form name="form2" id="form2" method="post" action="KQLR.asp" target="_self">

  <tr bgcolor="#009933">
    <td width="20" bgcolor="#B1DB99" align="center" height="40" style="border: 1px solid #000000" rowspan="2">
    ID</td>
    <td width="110" bgcolor="#B1DB99" align="center" height="40" style="border: 1px solid #000000" rowspan="2">
    班级</td>
    <td width="102" bgcolor="#B1DB99" align="center" height="40" style="border: 1px solid #000000" rowspan="2">
    学号</td>
    <td width="49" bgcolor="#B1DB99" align="center" height="40" style="border: 1px solid #000000" rowspan="2">
    姓名</td>
    <td width="19" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    学期</td>
    <td width="105" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    科目</td>
    <td width="30" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    面授次数</td>
    <td width="28" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    20%</td>
    <td width="33" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    作业成绩</td>
    <td width="31" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    10%</td>
    <td width="30" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    考试成绩</td>
    <td width="33" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    70%</td>
    <td width="42" align="center" height="40" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    总评分</td>
    <td width="138" align="center" height="20" bgcolor="#B1DB99" style="border: 1px solid #000000" colspan="3">
    补&nbsp; 考</td>
  </tr>
  <tr>
    <td width="42" align="center" height="21" bgcolor="#B1DB99" style="border: 1px solid #000000">
    第一次</td>
    <td width="44" align="center" height="21" bgcolor="#B1DB99" style="border: 1px solid #000000">
    第二次</td>
    <td width="38" align="center" height="21" bgcolor="#B1DB99" style="border: 1px solid #000000">
    第三次</td>
  </tr>
  <% For i = 1 to LoopNum %>
  <tr bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#FFFFCC'" onMouseOut="this.style.backgroundColor='#FFFFFF'">
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="20">
                    <input type="checkbox" name="checkbox" value="<%=rs("id")%>" checked></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="110">
     <%=rs("class")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="102">
    <%=rs("sno")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="49">
    <a href="DetailStudent_cj.asp?sno=<%=rs("sno")%>"><%=rs("name")%></a></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000"><%=rs("xueqi")%></td>
   
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000">
    <%=rs("kemu")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000"><%=rs("chuqincishu")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000">
    <%=rs("chuqindefen")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000"><%=rs("zuoyefenshu")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="31"><%=rs("zuoyedefen")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="30">
    <%=rs("kaoshifenshu")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="33">
    <%=rs("kaoshidefen")%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="42">
    <%if rs("zongpingfen") < 60 then %><font color=#FF0000> <%=rs("zongpingfen")%> </font><%else%><font color="#000080"> <%=rs("zongpingfen")%> </font> <%end if%></td>
</td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="42">
    <%if rs("bukao1") < 60 then %><font color=#FF0000> <%=rs("bukao1")%> </font><%else%><font color="#000080"> <%=rs("bukao1")%> </font> <%end if%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="44">
    <%if rs("bukao2") < 60 then %><font color=#FF0000> <%=rs("bukao2")%> </font><%else%><font color="#000080"> <%=rs("bukao2")%> </font> <%end if%></td>
    <td align="center" height="25" bgcolor="#EBEBEB" style="border: 1px solid #000000" width="44">
    <%if rs("bukao3") < 60 then %><font color=#FF0000> <%=rs("bukao3")%> </font><%else%><font color="#000080"> <%=rs("bukao3")%> </font> <%end if%></td>
  </tr>
  <%   rs.movenext
      Next %>
  <tr>

    <td colspan="16" bgcolor="#B3CBFF" width="0" height="23"><div align="center">
        总共找到<%=Num%>条记录&nbsp;<a href="index_student_kq.asp?page=1"><font color="#0000FF">首页</font></a><font color="#0000FF">&nbsp;</font><a href="index_student_kq.asp?page=<%=page-1%>"><font color="#0000FF">上一页</font></a><font color="#0000FF">&nbsp;</font><a href="index_student_kq.asp?page=<%=page+1%>&xueqi=<%=strxq%>&kemu=<%=strkc%>"><font color="#0000FF">下一页</font></a><font color="#0000FF">&nbsp;</font><a href="index_student_kq.asp?page=<%=pageNum%>"><font color="#0000FF">尾页</font></a>&nbsp;页次:<%=page%>/<%=pagenum%>&nbsp;共<%=pageNum%>页</div></td>
  </tr>
    <tr>
    <td colspan="16" bgcolor="#C2A6FF" width="0" height="20">
    <p align="center">
                <input type="submit" name="Submit" value="  进入添加所选中学生的考勤次数  " style="border: 1pt solid #EEEEEE">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="reset" name="Submit2" value="  重新选择  " style="border: 1pt solid #EEEEEE"></td>
  </tr>
</table>
<%    
    Else
%>
<table width="808" style="border-collapse: collapse">
  <tr bgcolor="#009933">
    <td colspan="12" bgcolor="#B3CBFF" height="24"> </td>
  </tr>
  <tr bgcolor="#009933">

    <td width="68" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    学期</td>
    <td width="123" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    科目</td>
    <td width="57" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    面授次数</td>
    <td width="45" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    20%</td>
    <td width="57" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    作业成绩</td>
    <td width="47" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    10%</td>
    <td width="54" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    考试成绩</td>
    <td width="39" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    70%</td>
    <td width="45" align="center" height="34" bgcolor="#B1DB99" style="border: 1px solid #000000" rowspan="2">
    总评分</td>
    <td width="141" align="center" height="18" bgcolor="#B1DB99" style="border: 1px solid #000000" colspan="3">
    补&nbsp; 考</td>
  </tr>
  <tr>
    <td width="47" align="center" height="17" bgcolor="#B1DB99" style="border: 1px solid #000000">
    第一次</td>
    <td width="48" align="center" height="17" bgcolor="#B1DB99" style="border: 1px solid #000000">
    第二次</td>
    <td width="48" align="center" height="17" bgcolor="#B1DB99" style="border: 1px solid #000000">
    第三次</td>
  </tr>

  <tr>
    <td colspan="12" bgcolor="#EBEBEB" height="32" style="border: 1px solid #000000">
    <p align="center">没有相关记录!</td>
  </tr>

  <tr>
    <td colspan="5"></td>
  </tr>
</table>        
<%        
    End If
%>
</body>
</html>
搜索更多相关主题的帖子: asp 查询 
2008-05-12 11:57
acnch1
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-5-13
收藏
得分:0 
要么用GET
要么用SESSION
<input type="submit" name="search" value="搜索"/>

给他加个值
if requst("search")="搜索" or isempty(session("str")) then
session("str")=strSql
end if
rs.open session("str"),conn,1,1

用get比较麻烦一些
。。就是比较长。我就不写了
不过就算这样
我也觉得有瑕疵
因为你点下一页的时候
你的搜索条件全会跳到默认值
解决方法有几种
建议用框架
2008-05-13 02:32
liurr111
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-5-13
收藏
得分:0 
谢谢,我试试
谢谢,我试试
2008-05-13 16:17
liurr111
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-5-13
收藏
得分:0 
不行呀,提示错误
Microsoft VBScript 运行时错误 错误 '800a000d'

类型不匹配: 'requst'

/xlbgl/jx/web/Index_student_KQ.asp,行 139
应该加到哪里?
2008-05-13 16:29
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
requst拼写错误,改成Request
其他错误慢慢调试
2008-05-13 16:41
liurr111
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-5-13
收藏
得分:0 
我也看到了,可是没有反应,能不能告诉我加到哪里?谢谢
<%
    Dim strSearchSql ,strKc ,strBy ,strBj ,strBy0,strxq
    strBy = Request.form("By")
    strBy0 = Request.form("By0")
    strBj = trim(Request.form("classid"))
    strKc = Request.form("Kc")
    strxq = Request.form("xq")
    
    If strBj <> "" And  strBy <> "" and strKc <> "" and strby0 <> "" Then
        If strBy = "zp" and strby0 = "全部" Then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"'"
        elseIf strBy = "zp" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen > 59"
        elseIf strBy = "zp" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen < 60"
        elseIf strBy = "bukao1" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 > 59"
        elseIf strBy = "bukao1" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 < 60"
        elseIf strBy = "bukao2" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 > 59"
        elseIf strBy = "bukao2" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 < 60"
        elseIf strBy = "bukao3" and strby0 = "及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 > 59"
        elseIf strBy = "bukao3" and strby0 = "不及格" then
            strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 < 60"


        Else
            strSearchSql = "WHERE "& strBy &" = '"& strBj &"' and kemu = '"& strKc &"'"
        End If    
    Else
        strSearchSql = "WHERE class = '"& bj &"'"

    End If
    Dim rs,rs11,rs22 ,strSql ,Num ,pageNum ,page ,loopNum
    strSql = "SELECT * FROM Student_cj " & strSearchSql
        Set rs = Server.CreateObject("ADODB.Recordset")

        rs.open strSql,conn,3,3
       
       
'if request("search")="搜索" or isempty(session("str")) then
'session("str")=strSql
'end if
'rs.open session("str"),conn,1,1
    
%>
<%
    If rs.recordcount > 0 Then
        rs.pagesize = 14
        Num = rs.recordcount
        pageNum = rs.pagecount
        page =  Request.QueryString("page")
        If page <> ""  Then
            page = Cint(page)
        ElseIf page < 1 Then
            page = 1
        Else
            page =1
        End If
        If page < 1 then
            page =1
        End If
        If page*rs.pagesize >Num and Not ((page-1)*rs.pagesize <Num) Then
            page = 1
        End If
        rs.absolutepage = page
        If page <> pageNum Then
            LoopNum = rs.pagesize
        Else
            LoopNum = Num - (page-1)*rs.pagesize
        End If
    
%><input type="submit" name="search" value="搜索"/>
2008-05-13 16:48
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
比如这样 (我没用红色注释掉的内容)
strBy = Request.form("By")
    strBy0 = Request.form("By0")
    strBj = trim(Request.form("classid"))
    strKc = Request.form("Kc")
    strxq = Request.form("xq")
改成
strBy = Request("By")
    strBy0 = Request("By0")
    strBj = trim(Request("classid"))
    strKc = Request("Kc")
    strxq = Request("xq")

<a href="index_student_kq.asp?page=<%=page+1%>&xq=<%=strxq%>&kc=<%=strkc%>&classid=<%=strBj%>&By=<%=StrBy%>&By0=<%=strBy0%>"><font color="#0000FF">下一页</font></a>
2008-05-13 17:05
liurr111
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-5-13
收藏
得分:0 
楼上的,前面我就是这样搞的,也不行
参数过不去
2008-05-13 17:08
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
request.form 改成 request 了吗?
2008-05-13 19:52
qazqaz111
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-5-12
收藏
得分:0 
改了还是不行
我能不能把源代码和数据库给您发过去您帮忙给看看?
2008-05-14 00:57
快速回复:asp组合查询分页问题,请教高手
数据加载中...
 
   



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

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