关于分页查询
anxl 2003-09-29 05:39:41 以下是一个后台查询源码,在执行分页时出现错误?请路过的高手务必帮忙看一下?因为对我来说很重要?非常诚恳的请求!谢谢!
这是查询语句
<%
dim conn
on error resume next
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "dsn=lxd;uid=;pwd=;"
%>
<%
const MaxPerPage=20
dim totalPut
dim category
dim CurrentPage
dim TotalPages
dim i
dim filename
dim categoryid
jm = request.form("jm")
jx =request.form("jx")
nd = request.form("nd")
js = request.form("js")
%>
<%
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
filename="yphj_search.asp"
dim sql
dim rs
if jm <> "" and jx = "" then
condition = "prize.PRIZE like '%" & jm & "%'"
end if
if jx <> "" and jm = "" then
condition = "prize.KIND like '%" & jx & "%'"
end if
if jm <> "" and jx <> "" then
condition = "prize.PRIZE ='" & jm & "' and prize.KIND ='" & jx & "'"
end if
if jm = "" and jx = "" then
condition = "false"
end if
if condition <> "false" then
if nd <> "" then
condition = condition & " and prize.PYEAR =" & Cint(nd)
end if
if js <> "" then
condition = condition & " and prize.Parray =" & Cint(js)
end if
else
if nd <> "" then
condition = " prize.PYEAR =" & Cint(nd)
end if
if js <> "" and condition = "false" then
condition = " prize.Parray =" & Cint(js)
else
if js <> "" then
condition = condition & " prize.Parray =" & Cint(js)
end if
end if
end if
sql = "select lxzlt.zlno as lzlno,lxzlt.Name as orname, lxzlt.Cname as Cname, lxzlt.Director as Director, lxzlt.content as content, lxzlt.hints as hints, lxzlt.lang as lang, lxzlt.minutes as minutes, lxzlt.kinds as kinds,lxzlt.Counts as Counts from lxzlt,prize where lxzlt.zlno = prize.zlno and " & condition
Set RS = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,3,1
if rs.eof then
response.write "<meta http-equiv=refresh content=""3;URL=yphj.htm""><p align=center><font size=5 color=red>您的请求不存在!页面将在3秒后自动返回。</font></p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,filename
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,filename
else
currentPage=1
showContent
showpage totalput,MaxPerPage,filename
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
number=maxperpage*(currentpage-1)+1
dim i
i=0
%>