asp:网页提示超时,代码错在哪里?

来源:百度知道 编辑:UC知道 时间:2024/06/04 16:49:22
我有一个页面是用其他页面修改的,但是点击连接后浏览器就超慢。最后提示:Active Server Pages 错误 'ASP 0113',脚本超时。
我的程序源码如下(部分)
id=request("id")
if id<>"" then
sql="select * from gonggao where xianqu='"&session("xianqu")&"' and id="&id
else
sql="select top 1 * from gonggao where xianqu='"&session("xianqu")&"' order by id desc"
end if
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
while not rs2.eof
title=rs2("Gtitle")
author=rs2("author")
content=rs2("Gcontent")
Addtime=rs2("addtime")
wend
rs2.close
set rs2=nothing

请大家看看错误出在哪里?肯定不应该出现脚本超时问题。已经排除其他的地方有故障的可能。
实现的功能是,当用户访问时,显示最新公告,当用户点击选择了某条公告,则根据id显示公告。
所以不需要rs.movenext,也不需要在第一条记录使用top

把上面的部分改成这样看看:

id=request("id")
if id<>"" then
sql="select top 1* from gonggao where xianqu='"&session("xianqu")&"' and id="&id
else
sql="select top 1 * from gonggao where xianqu='"&session("xianqu")&"' order by id desc"
end if

既然不需要循环,你用while干什么???
直接用if then ..... end if

rs.movenext
你要加这个啊.