文章 上一篇 下一篇功能

as83255743as 2012-08-10 05:07:20

<%
id=request.QueryString("id")
set rs=server.CreateObject("adodb.recordset")
sqlstr="select * from shenbao where S_ID="&id
rs.open sqlstr,conn,1,3
%>
中间的内容省略这段内容没有问题 加了下面的上下篇功能出错求人帮忙看看
<%
rs.close
%>
<%
sql="select top 1 * from shenbao where S_ID < "&id&" order by S_ID"

rs.open sqlstr,conn,1,3

if rs.eof then

response.Write("")

else

id1=rs("S_ID")

response.Write("<a href='shgxx.asp?id="&id1&"'>上一篇</a>")

end if
rs.close
%>
<%
sql="select top 1 * from shenbao where S_ID > "&id&" order by S_ID"

rs.open sqlstr,conn,1,3

if rs.eof then

response.Write("")

else

id1=rs("S_ID")

response.Write("<a href='shgxx.asp?id="&id1&"'>下一篇</a>")

end if
%>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>

...全文
108 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
scscms太阳光 2012-08-10
  • 打赏
  • 举报
回复
//献出我的私房菜
set nRs=server.CreateObject("adodb.recordset")
sql="select S_ID from [shenbao] order by S_ID"
nRs.open sql,conn,1,1
nRs.find str&"="&int(id)
nRs.MovePrevious
if nRs.bof then
Response.write "没有上一条"
else
Response.write "<a href='shgxx.asp?id="&nRs(0)&"'>上一条</a> "
end if
nRs.Move 2
if nRs.eof then
Response.write "没有下一条"
else
Response.write "<a href='shgxx.asp?id="&nRs(0)&"'>下一条</a>"
end if
nRs.close:set nRs=Nothing
  • 打赏
  • 举报
回复
因为你关闭了rs.close
下面还用,就出错了
这一点最好是每次使用以后即使关闭和释放
目前就根据这些代码,就只有这一点造成错误了
htpower 2012-08-10
  • 打赏
  • 举报
回复
这个有什么问题吗?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧