本模块为数据查询页面:其中,sjk.asp文件,页面默认从数据表中读取所有的单据记录,然后进行分页显示:页面跳转的功能就是使用 “首页”“上一页”“下一页”“尾页”进行页面之间的跳转;在这个页面中,分页显示正常;
但是,我想在查询结果显示页面中也实现类似的功能,但是,问题却出现了:当我输入查询关键字,点击查询以后,返回的查询结果集是正常的(也就是说,SQL语句不存在问题);但是,当我点击“上一页”或者“下一页”时,显示的记录集却变成了所有的记录集;而不是查询结果集中的记录。
被这个问题已经困扰了好几天了,请各位大虾多多指教 !!

默认打开数据库全部文件,分页显示正常。

按条件搜索结果也都正常,但是点击“下一页”结果变成全部数据的“下一页”了。
代码如下 :
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
dim conn,rs,page '连接数据库
dim cj,zt,jx,ch,flag
set conn=server.CreateObject("adodb.connection")
conn.open "dsn=mysql_churuku;uid=root;pwd=admin"
set rs=server.CreateObject("adodb.recordset")
rs.cursorlocation=3
cj=trim(request("chejian")) '从表单中取得搜索条件
zt=trim(request("zhuangtai"))
jx=trim(request("jixing"))
ch=trim(request("chehao"))
sql="select * from churuku where"
flag=0 '按照搜索条件连接SQl语句
if cj<>"" then
sql=sql&" chejian='"&cj&"'"
flag=1
end if
if zt<>"" and flag=1 then
sql=sql&" and zhuangtai='"&zt&"'"
elseif zt<>"" then
sql=sql&" zhuangtai='"&zt&"'"
flag=1
end if
if jx<>"" and flag=1 then
sql=sql&" and jixing='"&jx&"'"
flag=1
elseif jx<>"" then
sql=sql&" jixing='"&jx&"'"
flag=1
end if
if ch<>"" and flag=1 then
sql=sql&" and chehao='"&ch&"'"
elseif ch<>"" then
sql=sql&" chehao='"&ch&"'"
flag=1
end if
if flag=0 then
sql="select * from churuku"
end if
rs.open sql,conn,1,1
rs.pagesize=10 ' 每页10条显示数据库内容
page=clng(request("page"))
if page <1 then page=1
if page >rs.pagecount then page=rs.pagecount
if rs.pagecount>0 then rs.AbsolutePage=page
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form id="form2" name="form2" method="post" action="sjk.asp">
<table ""style="text-align:center" width="100%" border="1" align="center" cellpadding="1" cellspacing="0">
<tr bgcolor="#FFFF99" align="center">
<td > </td>
<td>日期 </td>
<td>车间</td>
<td>班次</td>
<td>机型</td>
<td>车号</td>
<td>车次</td>
<td>司机</td>
<td>时间</td>
<td>状态</td>
<td>查看修改</td>
<td>删除</td>
</tr>
<%
for i=1 to rs.pagesize
if rs.eof then exit for
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("riqi")%></td>
<td><%=rs("chejian")%></td>
<td><%=rs("banci")%></td>
<td><%=rs("jixing")%></td>
<td><%=rs("chehao")%></td>
<td><%=rs("checi")%></td>
<td><%=(rs("siji"))%></td>
<td><%=rs("shijian")%></td>
<td style="color:#933"><% =rs("zhuangtai")%></td>
<td>查看修改</td>
<td>删除</td>
</tr>
<%
rs.movenext
next
%>
</table>
<p> </p>
<p style="text-align:center; text-indent:40px"> '分页显示
<% if rs.pagecount >0 then %>
当前页:<%=page%>/<%=rs.pagecount%> | 每页: <%=rs.pagesize%> 条信息 | 共 <%=rs.recordcount%> 条信息
<% else %>
当前页: 0/0
<%end if %>
<% if page >1 then %>
<a href="sjk.asp?page=1">首页</a> |
<a href="sjk.asp?page=<%=page-1%>"&cj=<%=request("chejian")%>&z=<%=request("zhuangtai")%>&jx=<%=request("jixing")%>&ch=<%=request("chehao")%>&action=<%=request("action")%>>上一页</a> |
<% end if %>
<%if page<>rs.pagecount then %>
<a href="sjk.asp?page=<%=page+1%>"&cj=<%=request("chejian")%>&z=<%=request("zhuangtai")%>&jx=<%=request("jixing")%>&ch=<%=request("chehao")%>&action=<%=request("action")%>>下一页</a> |
<a href="sjk.asp?page=<%=rs.pagecount%>">尾页</a> |
<% end if %>
'搜索条件
<p > 车间:<select name="chejian" id="chejian" style="text-align:center;width:100Px;height:25px">
<option value=" "> </option>
<option value="大连"<%if request.form("chejian")="大连" then response.Write"selected"%>>大连</option>
<option value="金州"<%if request.form("chejian")="金州" then response.Write"selected"%>>金州</option>
</select>
状态:
<select name="zhuangtai" id="zhuangtai" style="width:100Px;height:25px">
<option value=" "> </option>
<option value="入库"<%if request.form("zhuangtai")="入库" then response.write"selected"%>>入库</option>
<option value="出库"<%if request.form("zhuangtai")="出库" then response.write"selected"%>>出库</option>
</select>
<input type="submit" name="button" id="button" style="width:200px;height:150" value="提 交" />
机型:
<select name="jixing" id="jixing" style="width:100Px;height:25px">
<option value=" "> </option>
<option value="HXD2"<% if request.form("jixing")="HXD2" then response.Write"selected"%>>HXD2</option>
<option value="HXD3B"<% if request.form("jixing")="HXD3B" then response.Write"selected"%>>HXD3B</option>
<option value="ND5"<% if request.form("jixing")="ND5" then response.Write"selected"%>>ND5</option>
</select>
车号:
<input type="text" name="chehao" id="chehao" style=" height:24px" size="12"/>
</form>
</body>
</html>