ASP查询分页问题

来源:百度知道 编辑:UC知道 时间:2024/05/14 10:21:31
下面代码,数据库明明有几页查询结果,但是只可以查询到第一页,点击下一页就不是查询的结果了,请指点。
<!--#include file="conndb.asp"-->
<%
textT=request("textT")
textT=request.form("textT")
dim rs
set rs=server.createobject("adodb.recordset")
sql="select * from khdd where ddID like '%"&textT&"%'"
set rs.activeconnection=conn
rs.cursortype=3
rs.open sql,conn,1,1
%>
<br>
<%
If rs.EOF Then
Response.Write "<tr><td colspan=10 align=center>目前还没有订单记录。</td></tr></table>"
Else
'设置每页显示记录的数量
rs.PageSize = 20
'读取参数page,表示当前页码
iPage = CLng(Request("page"))
If iPage > rs.PageCount Then
iPage = rs.PageCount
End If
If iPage <= 0 Then
iPage = 1
End If
rs.AbsolutePage = iPage

For i=1 To rs.PageSize
n = n + 1

'来个新的分页方法
'无错分页方法
'下面这个函数可以包含在连接页面中供所有页面调用
'html-encode:格式化HTML字符(可能无法正常显示,BAIDU格式化了^_^)
function lq_code_html(lq_code_html_tmp)
if not isnull(lq_code_html_tmp) then
lq_code_html_tmp=server.htmlencode(lq_code_html_tmp)
lq_code_html_tmp=replace(lq_code_html_tmp,"\","\")
lq_code_html_tmp=replace(lq_code_html_tmp,"'","'")
lq_code_html_tmp=replace(lq_code_html_tmp,vbCrlf,"<br>")
lq_code_html = lq_code_html_tmp
end if
end function

'获取查询内容关键字由
nr=lq_code_html(Request("nr"))

'注意在查询输入表单中将输入nr的Value设置为<%=nr%>以方便下次调用
'获取页面
page=lq_code_html(Request("page"))
'如果不是数字则初始化为第一页
if not isnumeric(page) then
page=1
else
page=Clng(page)
end if
'初始化查询语句[下面fws_upfile为查询的表名]
sql="Select * from [fws_upfile]"
'如果查询关键字不为空[