<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim date1,datestart,dateend,szSql,rs,sql,pages,currentcount,kww,b
date1=trim(request.Form("date1"))
datestart=trim(request.Form("datestart"))
dateend=trim(request.Form("dateend"))
title=trim(request.Form("title"))
titlekeyword=trim(request.Form("titlekeyword"))
leibie=trim(request.Form("leibie"))
b="select * from kww where 1=1 "
if trim(request.Form("date1"))="全部" and trim(request.Form("title"))="全部" and trim(request.Form("leibie"))="全部" then
b="select * from kww where "
else
if date1<>"全部" and datestart<>"" and dateend<>"" then
b=b & " and finddate>" & "'"&datestart &"*'" & " and finddate<"& "'"&dateend &"*'"
end if
if title<>"全部" and titlekeyword<>"" then
b=b & " and " &title & " like '%" & titlekeyword & "%'"
end if
end if
end if
szSql=b
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 3</title>
</head>
<body>
<%
'定义SQL语句,页数和当前页变量
'dim sql,pages,currentcount
'sql="select * from kww "
pages=cint(request("pages"))
'创建一个Connection对象
set conn=server.CreateObject("adodb.connection")
conn.Open "Provider=SQLOLEDB.1;" _
& "User id=sa;" _
& "Password=;" _
& "Initial Catalog=kww;" _
& "Data Source=192.168.11.24"
'创建一个Recordset对象
set rs=server.createobject("adodb.recordset")
'传递SQL语句和其他参数
rs.open szSql,conn,3
'如果请求字符串为空,则将当前页设为第一页,如果不是为空则需要移动记录游标到相应的位置
if pages=0 then
pages=1
else
rs.move (pages-1)*rs.pagesize
end if
'判断当前页是否是最后一页,如果不是则将本页记录数设为pagesize属性值,如果是最后一页则利用记录总数recordcount,当前页pages和每页的记录数pagesize来计算当前页的记录数
if pages< rs.pagecount then
currentcount=rs.pagesize
else
currentcount=rs.recordcount-(pages-1)*rs.pagesize
end if
%>
<div align ="center">
<p>一共查找到<%=rs.recordcount%>条记录,分
<%=rs.pagecount %>
页,本页为第<% =pages %>页,有<% =currentcount %> 条记录
</p>
</div>
<table width ="75%" border ="1" align ="center">
<tr>
<td width="17%">url</td>
<td width="33%">webname</td>
</tr>
<%
'使用循环来输出检索出的数据
for i=1 to rs.pagesize
%>
<tr>
<td width ="17%"><% =rs("url")%></td>
<td width ="33%"><% =rs("webname")%></td>
</tr>
<%
'如果没有到记录尾,则游标移动到下一条记录
if not rs.eof then rs.movenext
'如果到了记录尾则跳循环,注意此处的rs.movenext与exit for之间不能使用if ....else结构,因为对应于exit for 判断需要在rs.movenext之后进行
if rs.eof then exit for
next
%>
</table>
<p align ="center">
<%
if pages>1 then
response.write "<a href='ddd.asp?pages="&pages-1&"'>前一页</a> "
else
response.write "前一页 "
end if
'为每页加上连接
for i=1 to rs.pagecount
if pages=i then
response.write " "
else
response.write "<a href='ddd.asp?pages="&i&"'>"&i&"</a>"
end if
response.write " "
next
'输出后一页的链接,如果已经为最后页,则没有超级链接
if pages<rs.pagecount then
response.write "<a href='ddd.asp?pages="&pages+1&"'>后一页</a>"
else
response.write "后一页"
end if
'关闭连接
rs.close
set rs=nothing
%>
</body>
</html>
为什么得到查询后显示的查询结果第一页是正常的,而点第二页时就变为全部纪录的第二页了,不是查询结果的第二页了,这是为什么,请帮助