关于查询结果的分页问题
我看了看以前的相关帖子,不过没有找到答案,只有在这贴出来问问各位朋友了。我的问题是,查询出结果并用分页显示,当查询完显示的时候,第一页是正常的,点击下一页就不行了,显示
Script error detected at line 14.
Source line: rs.Open sql,con,1,1
Description: ODBC 驱动程序不支持所需的属性
不清楚怎么回事,还是在分页的地方要传个什么值啊,我把部分代码贴出来,大家帮忙看看吧(ASP+access数据库)。
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../connections/ggcon.asp" -->
<% If session("login")=1 Then %>
<%
set rs = Server.CreateObject("ADODB.Recordset")
searchword=request.Form("searchword")
aform=request.Form("class")
sql = "SELECT * FROM message where class="&aform&" order by id desc"
rs.Open sql,con,1,1
%>
<%
intPage=trim(Request.queryString("page"))
if intPage="" then
intPage=1
elseif not isNumeric(intPage) then
intPage="0"
elseif intPage>2147483647 or intPage<0 then
intPage="0"
else
intPage=cint(intPage)
end if
if intPage="0" then
intPage=1
end if
%>
<style type="text/css">
<!--
.STYLE1 {font-size: larger}
-->
</style>
<form method="post" action="listsearch.asp">'当前页就是listsearch.asp
<div align="right">
<select name="class">
<%do while not lrs.eof %>
<label>
<option value="<%=lrs("id")%>"><%=lrs("class")%></option>
</label>
<%lrs.movenext
loop
lrs.close%>
</select>
<input type="submit" name="button" value="选择类别查询">
</div>
</form>
<%
if not rs.EOF then
dim strLocation
strLocation="listsearch.asp?"
rs.PageSize=6
intPagesize=rs.PageSize
intPagecount=rs.PageCount
if intPage>intPagecount Then
intPage=intPagecount
end if
intRecordcount=rs.RecordCount
intRecordStart=(intPage-1)*intPagesize+1
if intRecordStart+intPagesize-1>intRecordcount then
intRecordEnd=intRecordcount
else
intRecordEnd=intRecordStart+intPagesize-1
end if
rs.AbsolutePosition=intRecordStart
%>
<table width="899" height="62" border="1" align="center">
<tr>
<td width="128" align="center"><span class="STYLE1">类别</span></td>
<td width="230" align="center"><span class="STYLE1">标题</span></td>
<td width="341" align="center"><span class="STYLE1">添加日期</span></td>
<td width="182" align="center"><span class="STYLE1">操作</span></td>
</tr>
<%
i=0
do while not rs.EOF and i<intPagesize
%>
<tr>
<td><div align="center"><%=rs("class")%></div></td>
<td><div align="center"><a href="message_look.asp?id=<%=rs("id")%>"><%=rs("title")%></div></td>
<td><div align="center"><%=rs("adddate")%></div></td>
<td><div align="center"><a href="message_edit.asp?id=<%=rs("id")%>">修改</a>
<a href="message_del.asp?id=<%=rs("id")%>">删除</a></div></td>
</tr>
<%
rs.movenext
i=i+1
loop
%> </table>
<br>
<table border="0" width="620px" cellpadding="0" height="11" class="tx9pt" cellspacing="0">
<tr>
<td width="100%" height="5" align=right>
<a href="<%=strLocation%>page=1" title="首页">首页</a>
<%if intPage=1 then%>
上一页
<%else%>
<a href="<%=strLocation%>page=<%=intPage-1%>" title="上一页">上一页</a>
<%end if%>
<%if intPage>=intPagecount then%>
下一页
<%else%>
<a href="<%=strLocation%>page=<%=intPage+1%>" title="下一页">下一页</a>
<%end if%>
<a href="<%=strLocation%>page=<%=intPagecount%>" title="尾页">尾页</a>
</td>
</tr>
</table>
<%else%>
<table width="620" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center"><br>目前还没有记录!</td>
</tr>
</table><br>
</html>
<%
end if
rs.close
con.close
Set rs=nothing
set con=nothing
%>
<%
else
response.redirect "../index.asp"
end if
%>