嵌套循环报错!!

fire_dreamland 2007-09-13 04:42:45
<% rst.open "select * from iclass where aclass='企业园地' order by sort asc",conn,1,1
do while not rst.eof
%>
<tr>
<td height="20"><span class="STYLE3"><img src="images/jiao.gif" width="4" height="5" />  <%=rst("bclass")%></span></td>
</tr>
<%
sql = "select * from news where aclass='企业园地' and bclass='"&rst("bclass")&"'order by news_date desc"
rs.open sql,conn,1,1
if rs.eof then
%>
<tr>
<td height="27" ><img src="images/point.gif" width="5" height="5" />  </td>
</tr>
<tr>
<td height="1" background="images/title_line_news.gif"></td>
</tr>
<tr>
<td height="27" ><img src="images/point.gif" width="5" height="5" />  </td>
</tr>
<tr>
<td height="1" background="images/title_line_news.gif"></td>
</tr>
<tr>
<td height="27" ><img src="images/point.gif" width="5" height="5" />  </td>
</tr>
<tr>
<td height="1" background="images/title_line_news.gif"></td>
</tr>
<tr>
<td height="27" ><img src="images/point.gif" width="5" height="5" />  </td>
</tr>
<tr>
<td height="1" background="images/title_line_news.gif"></td>
</tr>
<tr>
<td height="27" ><img src="images/point.gif" width="5" height="5" />  </td>
</tr>
<tr>
<td height="1" background="images/title_line_news.gif"></td>
</tr>
</table>
<%else%>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">

<%i=0
do while not rs.eof%>

<tr>
<td height="27">  <img src="images/point.gif" />  <a href="news_read.asp?warp=yes&action=2&id=<%=rs("news_id")%>&aclass=<%=rs("aclass")%>&bclass=<%=rs("bclass")%>&cclass=<%=rs("cclass")%>" target="_blank" class="a1" >
<% if len(rs("news_title"))>11 then%>
<%=Left(rs("news_title"),10)%>...
<%else%>
<%=rs("news_title")%>
<%end if%></a>
</td>
</tr>
<tr>
<td height="1" background="images/title_line_news.gif"></td>
</tr>
<% rs.movenext i=i+1 if i=3 then exit do loop %>
<%end if%>
<%
rst.movenext
loop
%> <% rs.close rst.close set rst = nothing %>
...全文
114 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ldlazl 2007-09-28
  • 打赏
  • 举报
回复
顶楼桑
没事来溜溜 2007-09-28
  • 打赏
  • 举报
回复
rs.close 的位置应该向上提~
cow8063 2007-09-13
  • 打赏
  • 举报
回复
怎么全部用同名呢RS??

一个RS在OPEN这之前必须CLOSE
fire_dreamland 2007-09-13
  • 打赏
  • 举报
回复
错误类型:
ADODB.Recordset (0x800A0E79)
对象打开时,不允许操作。
toury 2007-09-13
  • 打赏
  • 举报
回复
兄弟,贴了N多的代码,却不说报了什么错,在什么位置报错~~谁会有耐心一行行的看你代码啊,呵呵

简单的看了看,是你的rs.close放错位置了,把它放rst.movenext上面:
do while .....
do while....
......
loop
rs.close
rst.movenext
loop
fire_dreamland 2007-09-13
  • 打赏
  • 举报
回复
<% rst.open "select * from iclass where aclass='企业园地' order by sort asc",conn,1,1
do while not rst.eof
%>
<%
sql = "select * from news where aclass='企业园地' and bclass='"&rst("bclass")&"'order by news_date desc"
rs.open sql,conn,1,1
if rs.eof then
%>
<tr></tr>
<%else%>
<%i=0
do while not rs.eof%>
<%=rs("news_title")%>
<%end if%>
<% rs.movenext
i=i+1
if i=3 then exit do
loop
%>
<%end if%>
<%
rst.movenext
loop
%>
<%
rs.close
rst.close
set rst = nothing
%>

这是简化的

28,391

社区成员

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

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