查询分页中,点“下一页”没有反应。
我用ASP查询ACCESS数据库,有四个字段,用一个表单调用。不知错误出在哪?请高手指教。
源程序如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<title>文件查询</title>
<head>
<%
const MaxPerPage=5
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim page
page=1
%>
</head>
<body bgcolor=Thistle>
<P align=center><FONT size=5><strong>文件查询</strong>
<%
word=trim(request("word"))
dim mycon,con
Set con=Server.CreateObject("ADODB.Connection")
mycon= "DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("/study/search.mdb")
con.open mycon
set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT * FRoM redsearch where id like '%"&word&"%'",MyCon,1,1
if not(rs.eof and rs.bof) then
rs.movefirst
end if
rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1
If trim(Request("word"))<>"" then
CurrentPage= 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'> 没有查到要查的记录!</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
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
</FONT></P>
<P> 第<%=currentpage%>页,共<%=n%>页。共找到<%=rs.recordcount%> 条符合条件的纪录。</P>
<P>
<% k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='index.asp?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(k-1)+"&word="+word+"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b><a href=index.asp?page="+cstr(k+1)+"&word="+word+">下一页</a></b>] "
response.write "[<b><a href='index.asp?page="+cstr(n)+"&word="+word+"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
%>
</P>
<TABLE border=1 align=center>
<tr>
<%
for i= 0 to howmanyfields%>
<TD><div align="center"><B><%=rs(i).name%></B></div></TD>
<%
next
i=0
do while not rs.eof and i<maxperpage%>
<tr align=middle>
<%for j=0 to howmanyfields%>
<td> <%=rs(j)%></td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</TABLE>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>