| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 275 人关注过本帖
标题:菜鸟求教,分页出错
收藏  订阅  推荐  打印 
aspqwert
Rank: 1
等级:新手上路
帖子:4
积分:140
注册:2005-5-8
菜鸟求教,分页出错

两个文件的源码如下: ////////////////////////// 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 望各位高手百忙中抽空看看,小弟感激不尽,先谢谢啦

2005-5-9 11:22
hxfly
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:10
帖子:5638
积分:57240
注册:2005-4-7

ADODB.Recordset 错误 '800a0e78' rs对像出错(记录集不存在,缺少rs.open语句) 你自己看看吧 实在不行就把 rs.Close Set rs = Nothing cn.Close Set cn = Nothing 去掉试试

2005-5-9 13:17
regedit
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:19
帖子:950
积分:9754
注册:2004-6-8

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

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

最新作品:百货品牌商品资讯第一门户([url]http://www.ib100.com/[/url]),欢迎交流
2005-5-9 13:23
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.084062 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved