分页问题,急!
前面发过贴子,没得到答案,再问各位,我把代码简化了一下,大家再帮我看看,点击分页后得出的结果为全部,没按条件分页!
<html>
<head>
<title>利用ADO分页</title>
</head>
<body>
<!-- METADATA TYPE="typelib" File="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
Dim cn,rs,sh_name
Dim iPage
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "Driver={SQL Server};Server=cd;Database=ASPTest;" & _
"UID=sa;PWD=sa"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.PageSize = 1 '这个值读者在使用时可根据需要设置
sh_name=trim(Request("sh_name"))
rs.Open "SELECT * FROM Chapter8 where 名称 like '%"&sh_name&"%'",cn,adOpenStatic,adLockReadOnly
If Len(Request("page")) = 0 Then
iPage = 1
Else
iPage = Request("page")
End If
rs.AbsolutePage = iPage
%>
<p align="center">图书信息第<% =iPage%>页</p>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#111111" width="646" align="center">
<form name="1">
<input name="sh_name" type="text"/>
<input type="submit" name="Button1" value="查 询" id="Button1" />
</form>
<tr>
<td width="33">编号</td>
<td width="98">名称</td>
<td width="37">作者</td>
<td width="56">类别</td>
<td width="135">出版社</td>
<td width="69">出版日期</td>
<td width="33">价格</td>
<td width="39">页数</td>
</tr>
</tr>
<%
For i =1 To rs.PageSize
If Not rs.Eof Then
%>
<tr>
<td width="33"><%=rs(0)%> </td>
<td width="98"><%=rs(1)%> </td>
<td width="37"><%=rs(2)%> </td>
<td width="56"><%=rs(3)%> </td>
<td width="135"><%=rs(4)%> </td>
<td width="69"><%=rs(5)%> </td>
<td width="33"><%=rs(6)%> </td>
<td width="39"><%=rs(7)%> </td>
</tr>
<%
End If
If Not rs.Eof Then rs.MoveNext
Next
%>
</table>
<p align="center">
<% If CInt(iPage) = 1 Then %>
第一页|上一页|
<% Else %>
<a href="08_07.asp?page=1">第一页</a>|
<a href="08_07.asp?page=<% = iPage - 1 %>">上一页</a>|
<% End If %>
<% If CInt(iPage) = CInt(rs.PageCount) Then %>
下一页| 最后一页
<% Else %>
<a href="08_07.asp?page=<% = iPage + 1 %>">下一页</a>|
<a href="08_07.asp?page=<% = rs.PageCount %>">最后一页</a>
<% End If %>
<%
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
%>
</body>
</html>