| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 605 人关注过本帖
标题:菜鸟求教,分页出错
只看楼主 加入收藏
aspqwert
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-5-8
收藏
 问题点数:0 回复次数:2 
菜鸟求教,分页出错

两个文件的源码如下: ////////////////////////// a.asp ////////////<html> <head> <title>利用ADO分页</title> </head> <body> <% Dim cn,rs Dim iPage

Set cn = Server.CreateObject("ADODB.Connection") cn.Open "Driver={SQL Server};Server=zhuoming;Database=ASPTest;" & _ "UID=sa;PWD=19821204" Set rs = Server.CreateObject("ADODB.RecordSet") Set rs.ActiveConnection = Cn rs.PageSize = 2 '这个值读者在使用时可根据需要设置 rs.CursorType = 3 rs.Open "SELECT * FROM information"

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"> <tr>

<td width="20%">编号</td> <td width="20%">名称</td> <td width="20%">作者</td> <td width="20%">价格</td> <td width="20%">出版日期</td> </tr> </tr> <% For i =1 To rs.PageSize If Not rs.Eof Then %> <tr> <td width="20%"><%=rs(0)%> </td> <td width="20%"><%=rs(1)%> </td> <td width="20%"><%=rs(2)%> </td> <td width="20%"><%=rs(3)%> </td> <td width="20%"><%=rs(4)%> </td> </tr> <% End If If Not rs.Eof Then rs.MoveNext Next %> </table> <p align="center"> <% If CInt(iPage) = 1 Then %> 第一页|上一页| <% Else %> <a href="a.asp?page=1">第一页</a>| <a href="a.asp?page=<% = iPage - 1 %>">上一页</a>| <% End If %> <% If CInt(iPage) = CInt(rs.PageCount) Then %> 下一页| 最后一页 <% Else %> <a href="a.asp?page=<% = iPage + 1 %>">下一页</a>| <a href="a.asp?page=<% = rs.PageCount %>">最后一页</a> <% End If %> <% rs.Close Set rs = Nothing cn.Close Set cn = Nothing %> <form name="aform" method="post" action="b.asp"> 排列功能:<p> 请填入列名:<input name="lieming" type="text" size="10"> 升序<input name="pailie" type="radio" value="sheng" checked> 降序<input name="pailie" type="radio" value="jian"> <input name="submit2" type="submit" id="submit2" value="确定">    <input name="reset2" type="reset" id="reset2" value="取消"> </form> </body> </html> ///////////////////////////////////////////// b.asp: ///////////////////////// <html> <head> <title>利用ADO分页</title> </head> <body> <% Dim cn,rs Dim iPage dim lieming Set cn = Server.CreateObject("ADODB.Connection") cn.Open "Driver={SQL Server};Server=zhuoming;Database=ASPTest;" & _ "UID=sa;PWD=19821204" Set rs = Server.CreateObject("ADODB.RecordSet") Set rs.ActiveConnection = Cn rs.PageSize = 2 rs.CursorType = 3 lieming=request.form("lieming") pailie=request.form("pailie")

if pailie="sheng" then rs.Open "SELECT * FROM information order by '"&lieming&"' asc" elseif pailie="jian" then rs.Open "SELECT * FROM information order by '"&lieming&"' desc" end if 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"> <tr> <td width="20%">编号</td> <td width="20%">名称</td> <td width="20%">作者</td> <td width="20%">价格</td> <td width="20%">出版日期</td> </tr> </tr> <% For i =1 To rs.PageSize If Not rs.Eof Then %> <tr> <td width="20%"><%=rs(0)%> </td> <td width="20%"><%=rs(1)%> </td> <td width="20%"><%=rs(2)%> </td> <td width="20%"><%=rs(3)%> </td> <td width="20%"><%=rs(4)%> </td> </tr> <% End If If Not rs.Eof Then rs.MoveNext Next %> </table> <p align="center"> <% If CInt(iPage) = 1 Then %> 第一页|上一页| <% Else %> <a href="b.asp?page=1">第一页</a>| <a href="b.asp?page=<% = iPage - 1 %>">上一页</a>| <% End If %> <% If CInt(iPage) = CInt(rs.PageCount) Then %> 下一页| 最后一页 <% Else %> <a href="b.asp?page=<% = iPage + 1 %>">下一页</a>| <a href="b.asp?page=<% = rs.PageCount %>">最后一页</a> <% End If %> <% rs.Close Set rs = Nothing cn.Close Set cn = Nothing %> </body> </html> 第一页可以正确显示,第二页就不行了,错误如下:

ADODB.Recordset 错误 '800a0e78'

对象关闭时,操作不被允许。

/b.asp,行30 望各位高手百忙中抽空看看,小弟感激不尽,先谢谢啦

搜索更多相关主题的帖子: html title 读者 
2005-05-09 11:22
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
ADODB.Recordset 错误 '800a0e78' rs对像出错(记录集不存在,缺少rs.open语句) 你自己看看吧 实在不行就把 rs.Close Set rs = Nothing cn.Close Set cn = Nothing 去掉试试

2005-05-09 13:17
regedit
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:950
专家分:0
注 册:2004-6-8
收藏
得分:0 
if pailie="sheng" then
  rs.Open "SELECT * FROM information order by '"&amp;lieming&amp;"'  asc"
  elseif pailie="jian" then
  rs.Open "SELECT * FROM information order by '"&amp;lieming&amp;"'  desc"
  end if

仔细查看这里~
看看pailie的值有无传到

最新作品:百货品牌商品资讯第一门户([url]http://www./[/url]),欢迎交流
2005-05-09 13:23
快速回复:菜鸟求教,分页出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011799 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved