有关数据查询后分页显示数据的问题

di78da 2003-01-03 10:22:17
小弟在这里先谢了!问题,我做了个查询页面当我输入条件后,进入显示页面(由*.ASP引导)后第一页可以显示符合要求的记录,但当我点击下一页后,显示的记录就不在是我所要查询的记录了!问题在那里?原码如下:<% const maxperpage=3
dim SQLstr,rs,totalput,currentpage,totalpages,i,j%>

<%SQLstr=""
StationName=Request.Form("StationName")
DeviceName=Request.Form("DeviceName")
set rs = server.CreateObject ("ADODB.Recordset")
if StationName <>"" or DeviceName <>"" then
SQLstr= " SELECT * from DeviceBug where StationName Like '%"&Request("StationName")&"%'and DeviceName Like '%"&Request("DeviceName")&"%'"
else SQLstr= " SELECT * from DeviceBug "
end if
set rs = server.CreateObject ("ADODB.Recordset")
rs.Open SQLstr,conn,1,1
rs.MoveFirst
%>
<%
rs.PageSize=maxperpage
howmanyfields=rs.Fields.count-1
if trim(request("page"))<>""then
currentpage=clng(request("page"))
if currentpage>rs.PageCount then
currentpage=rs.PageCount
end if
else
currentpage=1
end if
if rs.EOF then
Response.Write"<p align='center'>error!</p>"
else
totalput=rs.RecordCount
if currentpage<>1 then
if (currentpage-1)*maxperpage<totalput then
rs.Move(currentpage-1)*maxperpage
dim bookmark
bookmark=rs.Bookmark
end if
end if
end if
dim n,k
if(totalput mod maxperpage)=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
%>
page<%=currentpage%>
of<%=n%>
共<font color=Black><%=rs.RecordCount%></font>条记录

<% k=currentpage

if page <>1 then
Response.Write "<a href=userud.asp?page="&page&">首頁</a>" & vbCrlf
end if
tmppage = currentpage - 1
if tmppage <= 0 then
tmppage = 1
else
Response.Write"<a href=userud.asp?page="&tmppage&">上一頁</a>"& vbCrlf
end if
tmppage = currentpage + 1
if tmppage > Rs.PageCount then
tmppage = currentpage
else
Response.Write "<a href=userud.asp?page="&tmppage&">下一頁</a>"&vbCrlf
end if

Response.Write"[<b>"+"<a href='userud.asp?page="+cstr(n)+"'>尾页</a></b>]"



%>


<TD width=150 align=middle><font face=宋体 size=2 color=aliceblue>变电站名称</font></TD>
<td width=150 align=middle><font face=宋体 size=2 color=aliceblue>设备名称</font></td>
<td width=100 align=middle><font face=宋体 size=2 color=aliceblue>设备编号</font></td>
<td width=100 align=middle><font face=宋体 size=2 color=aliceblue>设备类型</font></td>
<td width=100 align=middle><font face=宋体 size=2 color=aliceblue>发现时间</font></td>
<td width=60 align=middle><font face=宋体 size=2 color=aliceblue>发现人</font></td>
<td width=100 align=middle><font face=宋体 size=2 color=aliceblue>上报时间</font></td>
<td width=100 align=middle><font face=宋体 size=2 color=aliceblue>消除时间</font></td>
<td width=60 align=middle><font face=宋体 size=2 color=aliceblue>消除人</font></td>
<td width=60 align=middle><font face=宋体 size=2 color=aliceblue>验收人</font></td>
<td width=100 align=middle><font face=宋体 size=2 color=aliceblue>验收时间</font></td><tr>
<tr>
<%i=1
while not rs.EOF and i<=maxperpage
%>
<TR align=middle bgcolor=lightsteelblue>
<td width=80 align=middle ><font face=宋体 size=2>
<a href="userud_1.asp?stationName=<%=rs.Fields("stationName")%>">
<%=rs.Fields("stationName")%></a>
<td width=80 align=middle ><font face=宋体 size=2>
<%=rs("Devicename")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("DeviceNum")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("Devicetype")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("FindTime")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("Findperson")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("ReportTime")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("ResolveTime")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("Resolveperson")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("Checkperson")%></font></td>
<td width=100 align=middle ><font face=宋体 size=2>
<%=rs("CheckTime")%></font></td>
<tr>
<%i=i+1
rs.MoveNext
wend
%>
...全文
39 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

28,391

社区成员

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

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