求救高手!!分页问题!!!为何到下一页时,传递的参数没起作用?

jnsemt 2002-01-14 05:53:42
第一页按条件筛选了,但按下一页时,并没有按我要求的条件进行筛选,而是显示了所有记录???将光标放在到下一页的超级联接的时候会出现我的查询条件,怎么回事啊?是不是超级联接处的查询条件不对?已经4天了......救救我吧,一定送分!!

<%@ Language=VBScript EnableSessionState=true%>
<!--#include file ="call_interbase.asp"-->

<!--#include file = "adovbs.inc"-->
<HTML>
<HEAD>
<META name="VI60_DefaultClientScript" Content="VBScript">

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/THEME.CSS" VI6.0THEME="Expedition">
<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/GRAPH0.CSS" VI6.0THEME="Expedition">
<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/COLOR0.CSS" VI6.0THEME="Expedition">
<LINK REL="stylesheet" TYPE="text/css" HREF="_Themes/expeditn/CUSTOM.CSS" VI6.0THEME="Expedition"></HEAD>
<BODY>



<%
DIM RYBH,strMC
RYBH = Session("rybh")

dim objConn,objRs,strSQL

set objConn = Server.CreateObject ("adodb.Connection") '建立数据连接对象
set objRs = Server.CreateObject ("adodb.recordset")'建立记录集对象

objRs.CursorLocation =3
objRs.CursorType =3


objConn.open strConn
strsql= "SELECT C.*,B.RYBH, b.xm,d.mc FROM RECORD C, RYXX B,zdcs d WHERE B.RYBH='"&rybh&"' and c.kh=b.kh and c.jh=d.jh and d.mc like '%"&Request.Form ("sbmc")&"%' "'搜索满足条件的记录
objRs.Open strsql,strConn ,3,3 '打开记录集
Session("mc")=objRs("mc")

objRs.PageSize = 5 '设8笔记录为一页
if not IsEmpty(request("ToPage")) then

ToPage = CInt(request("ToPage"))
if ToPage > objRs.PageCount then
objRs.AbsolutePage =objRs.PageCount
else if ToPage<=0 then
objRs.AbsolutePage = 1
else
objRs.AbsolutePage = ToPage
end if
end if
end if



intPage = objRs.AbsolutePage'取出目前所指向的页码
%>
<A href = "yjjlsql.asp">
<FONT color=#3366ff face=宋体 size=5><STRONG>返回上一级</STRONG></FONT></a>
<p><P align=center><FONT color=#cc3333 face=宋体 size=5><STRONG>目前在第<% = intpage%>页,共有<% = objRs.PageCount %>页<%=objRs.RecordCount %>笔记录</STRONG></FONT>
<hr></p>
<p></p>

<TABLE width="100%" BGCOLOR=#cccccc BORDERCOLOR=#006666 BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR>
<TD><b>姓名</b></TD>
<TD><b>用户编号</b></TD>
<TD><b>卡号</b></TD>
<TD><b>帐户号</b></TD>
<TD><b>设备名称</b></TD>
<TD><b>开机日期</b></TD>
<TD><b>关机日期</b></TD>
<TD><b>用机金额</b></TD>
<TD><b>结算日期</b></TD>
</TR>
<%
for i=1 to objRs.PageSize
IF objRs.EOF then
exit for
End If
rem While Not objRs.EOF
%>
<TR>
<TD><%=objRs("xm")%></TD>
<TD><%=objRs("rybh")%></TD>
<TD><%=objRs("kh")%></TD>
<TD><%=objRs("zhh")%></TD>
<TD><%=objRs("mc")%></TD>
<TD><%=objRs("kjrq")%></TD>
<TD><%=objRs("gjrq")%></TD>
<TD><%=objRs("yjje")%></TD>
<TD><%=objRs("jsrq")%></TD>
</TR>

<% objRs.MoveNext
%>
<%next%>

</TABLE>

<TABLE>
<TR VALIGN = BASELINE ALIGN = CENTER>
<%
if intpage<>1 then
%>
<TD WIDTH = 150>
<A Href = yjjlsql1.asp?ToPage=<%=1%>&b.rybh="<%=session("rybh")%>"&c.kh="&b.kh&"&c.jh="&d.jh&"&d.mc="<%=session("mc") %>">到第一页</a>
</td>
<TD WIDTH = 150>
<A Href = yjjlsql1.asp?ToPage=<%=intpage - 1%>&b.rybh="<%=session("rybh")%>"&c.kh="&b.kh&"&c.jh="&d.jh&"&d.mc="<%=session("mc") %>">到上一页</a>
</td>
<%
end if
if intPage<>objRs.PageCount then
%>
<TD WIDTH = 150>
<A Href = yjjlsql1.asp?ToPage=<%=intpage+1%>&d.mc="<%=session("mc") %>"&b.rybh="<%=session("rybh")%>"&c.kh="&b.kh&"&c.jh="&d.jh&">到下一页</a>
</td>
<TD WIDTH = 150>
<A Href = yjjlsql1.asp?ToPage=<%=objRs.PageCount %>&b.rybh="<%=session("rybh")%>"&c.kh="&b.kh&"&c.jh="&d.jh&"&d.mc="<%=session("mc")%>">到最后一页</a>
</td>
<%
end if

%>
<TD WIDTH = 150>
<form action=yjjlsql1.asp method = post id=form1 name=form1>
<FONT color=#cc3333 face=宋体 size=3><STRONG> 到第
<input type="text" name = ToPage style ="height:25px;width:20px" value=<% = intpage%>>页</STRONG></FONT>

</td></tr>
</table>
</form>

<%
objRs.Close
objConn.Close
set objRs=Nothing
set objConn=nothing
%>

</BODY>
</HTML>









...全文
101 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
希偌 2002-01-14
  • 打赏
  • 举报
回复
或者你把
RYBH = Session("rybh")
-->
if Request.servervariables("CONTENT_LENGTH")=0 then
RYBH = Session("rybh")
else
RYBH = request("rybh")
end if
另外要注意把程序里相应的session("rybh")也改改~!
希偌 2002-01-14
  • 打赏
  • 举报
回复
我给个例子你吧!
<!--#include file="./include/conn.inc"-->

<%
const intpagesize=20
if Request("page")="" then
intcur=1
else
select case request("page")
case "first"
intcur=1
case "previous"
intcur=cint(request("curpage"))
intcur=intcur-1
case "next"
intcur=cint(request("curpage"))
intcur=intcur+1
case "last"
intcur=cint(request("lastpage"))
case else
intcur=request("page")
end select
end if
set rst=server.createobject("ADODB.recordset")
rst.CursorLocation=2
rst.CursorType=3
rst.CacheSize=intpagesize
straccess="select * from law where answer is not null and not answer like ''"
rst.open straccess,strconn
rst.PageSize=intpagesize
if Not rst.EOF then
rst.AbsolutePage=intcur
end if
inttotal=rst.pagecount
session("inttotal")=inttotal
rscount=rst.recordcount
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>法律咨询</title>
<style TYPE="text/css">
<!--

BODY {FONT-FAMILY: "宋体", "宋体"; FONT-SIZE: 9pt; LINE-HEIGHT: 12pt}
BR {FONT-FAMILY: "宋体", "宋体"; FONT-SIZE: 9pt; LINE-HEIGHT: 12pt}
TD {FONT-FAMILY: "宋体"; FONT-SIZE: 9pt; LINE-HEIGHT: 12pt}


a {COLOR: #000080; text-decoration: none}
a:hover {color:#ff0000;text-decoration:none}
.submit {line-height:9pt;font-size:9pt;font-family:宋体}
.submit1 {line-height:8pt;font-size:8pt;font-family:宋体}
.selectform {font-family: 宋体; font-size: 9pt;background-color:ffE4E4}
.td {font-family: 宋体; font-size: 9pt;background-color:ECF7FF}
.td1 {font-family: 宋体; font-size: 9pt;background-color:A2C8F2}
.td2 {font-family: 宋体; font-size: 9pt;background-color:E9EDE0}
.small1 {font-family: 宋体; font-size: 9pt;background-color:ffffff;line-height:9pt}
-->
</style>
</head>

<body bgcolor=#d0e3ff>

<p align="center"><font color="#ff0000" face="楷体_GB2312" size="5">法律咨询</font></p>
<center>
<table border="0" cellPadding="0" cellSpacing="0" width="100%">
<tbody>
<tr>
<td width="22%">【<a href="write.asp">我要提问</a>】</td>
<td width="78%">
<p align="right"><img src="images/ico.gif">总页数: <font color="red"><% =inttotal %>
</font>   <img src="images/amount.gif"> 论题数: <font color="red"><% =rst.recordcount %>
</font>   <img src="images/curpage.gif"> 当前页数: <font color="red"><% =intcur %>
</font>   </p>
</td>
</tr>
</tbody>
</table>
</center>
<div align="center">
<center>
<table border="0" cellPadding="0" cellSpacing="1" width="100%">
<tbody>
<tr>
<td align="middle" class="td1" height="15" width="62"><font color="#ff0000">序号</font></td>
<td align="middle" class="td1" height="20" width="424"><font color="#ff0000">主   题</font></td>
<td align="middle" class="td1" height="15" width="98"><font color="#ff0000">点击</font></td>
<td align="middle" class="td1" height="15" width="98"><font color="#ff0000">提问人</font></td>
<td align="middle" class="td1" height="15" width="218"><font color="#ff0000">提问时间</font></td>
<td align="middle" class="td1" height="15" width="105"><font color="#ff0000">回复专家</font></td>
<td align="middle" class="td1" height="15" width="47"><font color="#ff0000">字数</font></td>
</tr>
<%
i=0
do while not rst.eof and i<rst.PageSize
%>
<tr>
<td onmouseover="this.style.background='#fdf8ff'" onmouseout="this.style.background='#ECF7FF'" align="middle" bgColor="#004e9b" class="td" height="15" width="62"><font color="#000000"><% =rst("id") %></font></td>
<td onmouseover="this.style.background='#fdf8ff'" onmouseout="this.style.background='#ECF7FF'" align="middle" bgColor="#004e9b" class="td" height="20" width="424"><font color="#000000"><a href="read.asp?id=<% =rst("id") %>" target="_blank"><% =rst("title") %></a></font></td>
<td onmouseover="this.style.background='#fdf8ff'" onmouseout="this.style.background='#ECF7FF'" align="middle" bgColor="#004e9b" class="td" height="15" width="98"><font color="#000000"><% =rst("point") %></font></td>
<td onmouseover="this.style.background='#fdf8ff'" onmouseout="this.style.background='#ECF7FF'" align="middle" bgColor="#004e9b" class="td" height="15" width="98"><font color="#000000"><% =rst("question_man") %></font></td>
<td onmouseover="this.style.background='#fdf8ff'" onmouseout="this.style.background='#ECF7FF'" align="middle" bgColor="#004e9b" class="td" height="15" width="218"><font color="#000000"><% =rst("addtime") %></font></td>
<td onmouseover="this.style.background='#fdf8ff'" onmouseout="this.style.background='#ECF7FF'" align="middle" bgColor="#004e9b" class="td" height="15" width="105"><font color="#000000"><% =rst("answer_man") %></font></td>
<td onmouseover="this.style.background='#fdf8ff'" onmouseout="this.style.background='#ECF7FF'" align="middle" bgColor="#004e9b" class="td" height="15" width="47"><font color="#000000"><% =len(rst("question")) %></font></td>
</tr>
<%
i=i+1
rst.movenext
loop
%>
</tbody>
</table>
</center>
</div>
<center>
<table border="0" cellPadding="0" cellSpacing="1" width="100%" height="1">
<tbody>
<tr>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="86"><font color="#ff0000">总页数</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="86"><font color="#ff0000">论题数</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="86"><font color="#ff0000">每页显示数</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="86"><font color="#ff0000">当前页数</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="87"><font color="#ff0000">页数</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="87"><font color="#ff0000">首页</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="87"><font color="#ff0000">末页</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="87"><font color="#ff0000">上一页</font></td>
<td align="middle" bgColor="#004e9b" class="td1" height="18" width="87"><font color="#ff0000">下一页</font></td>
</tr>
<tr>
<td align="middle" class="td" width="86" height="1"><% =inttotal %>
</td>
<td align="middle" class="td" width="86" height="1"><% =rst.recordcount %>
</td>
<td align="middle" class="td" width="86" height="1"><% =intpagesize %>
</td>
<td align="middle" class="td" width="86" height="1"><% =intcur %>
</td>
<td align="middle" class="td" vAlign="middle" width="87" height="1">
<form name="inputform">
<select name="sel" onchange="goto();" size="1">
<option selected>跳转页数</option>
<%
aaa=0
DO WHILE NOT aaa = rst.pagecount %>

<option value="index.asp?Page=<% =aaa+1 %>&curpage=<% =intcur %>"><% =aaa+1 %></option>

<% aaa=aaa+1
loop
%>
</select></form></td>
<td align="middle" class="td" width="87" height="1">【<a href="index.asp?page=first">首页</a>】</td>
<td align="middle" class="td" width="87" height="1">【<a href="index.asp?page=last&lastpage=<% =inttotal %>">末页</a>】</td>
<td align="middle" class="td" width="87" height="1">【<% if intcur>1 then %><a href="index.asp?page=previous&curpage=<% =intcur %>">上一页</a><% else response.write "上一页" end if %>】</td>
<td align="middle" class="td" width="87" height="1">【<% if intcur<inttotal then %><a href="index.asp?page=next&curpage=<% =intcur %>">下一页</a><% else response.write "下一页" end if %>】
</td>
</tr>
</tbody>
</table>
</center>
<div align="center">
<center>
<table border="0" cellPadding="0" cellSpacing="0" width="100%">
<tbody>
<tr>
<td width="100%"> </td>
</tr>
<tr>
<td width="100%">
<p align="center">
点击<a href="javascript:a();">这里</a>进入管理
</p>
</td>
</tr>
</tbody>
</table>
</center>
</div>

</body>

</html>
<script>
<!--
function a() {window.open('manage.asp','','toolbar=no,scrollbars=no,width=250,height=350,resizable=no');}
function goto() {window.location.href=document.inputform.sel.value;}
//-->
</script>
wuxineyou 2002-01-14
  • 打赏
  • 举报
回复
忘记“=”了
<input type="hidden" name="sbmc" value="<%=request("sbmc")%>">
wuxineyou 2002-01-14
  • 打赏
  • 举报
回复
首先,不管我能不能帮我解决问题,我给你一点编写格式方面的建议。
变量或数据库的字段,尽量不要用拼音的简写,我看了半天才摸索出了你的一点命名习惯,“mc”就是“设备名称”,“rybh”就是“人员编号”,我说得对吧!
看看你的这句代码:
strsql= "SELECT C.*,B.RYBH, b.xm,d.mc FROM RECORD C, RYXX B,zdcs d WHERE B.RYBH='"&rybh&"' and c.kh=b.kh and c.jh=d.jh and d.mc like '%"&Request.Form ("sbmc")&"%' "'搜索满足条件的记录

想一想问题是不是出在Request.Form ("sbmc")上?
你点“下一页”重新提交的表单中,并没有重新传递“sbmc”这个表单域。
在“下一页”的表单中,添加一个隐藏域try try!!!如下:
<input type="hidden" name="sbmc" value="<%request("sbmc")%>">
jnsemt 2002-01-14
  • 打赏
  • 举报
回复
高手见笑了,刚学编程,谈不上什么风格?劳神了!!
baggio785 2002-01-14
  • 打赏
  • 举报
回复
如果是像beyond_xiruo(希偌)所说的(你的代码太乱了,我没有看),那就要
RYBH = request("rybh")
lanying 2002-01-14
  • 打赏
  • 举报
回复
你的程序的风格太差了,我实在不想看
jnsemt 2002-01-14
  • 打赏
  • 举报
回复
我该怎么做?能说详细一点吗?谢谢?
希偌 2002-01-14
  • 打赏
  • 举报
回复
当然啦!
你是用RYBH = Session("rybh")取值,而你的“下一页”是用querystring传递变量值,当然没有办法取到条件参数!

28,391

社区成员

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

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