写了段小程序,不知道哪里出现死循环了,谁帮忙看看啊

always82 2008-11-21 02:03:54
代码如下,请帮忙看看啊,谢谢啦
<%
set rsb=server.createobject("adodb.recordset")
sql="select bigclassid from bigclass order by bigclassid desc"
rsb.open sql,conn,1,1
bigclassid=Trim(rsb("bigclassid"))
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="249" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40"> </td>
<%set rs=server.createobject("adodb.recordset")
sql="select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
%>
<td width="209"><table width="209" height="158" border="0" cellpadding="4" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td bgcolor="#F0F0F0">
<table width="201" height="150" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><a href="uploadfile/<%=rs("picname")%>" rel="lightbox" title="效果展示."><img src="uploadfile/<%=rs("picname")%>" alt="" width="201" height="150" border="0" /></a></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12"> </td>
</tr>
<tr>
<td height="23" bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#F6F6F6">
<tr>
<td bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17"><img src="img/index_24_1.gif" width="17" height="17"></td>
<td height="23" class="xg1"><%=rs("title")%></td>
</tr>
<tr>
<td> </td>
<td class="xg2"><%=left(rs("content"),20)%>...</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<%
rs.close
set rs=nothing
%>
</tr>
</table></td>
<%
set rs=server.createobject("adodb.recordset")
sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid not in (select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc) and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
%>
<td width="341" valign="top">
<%
do while not rs.eof
%>
<table width="341" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="76"> <table width="66" height="51" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td bgcolor="#F0F0F0"> <table width="60" height="45" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="60" height="45" bgcolor="#FFFFFF"><a href="uploadfile/<%=rs("picname")%>" rel="lightbox" title="效果展示."><img src="uploadfile/<%=rs("picname")%>" alt="" width="60" height="45" border="0" /></a></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="253" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17"><img src="img/index_24_1.gif" width="17" height="17"></td>
<td height="23" class="xg1"><%=rs("title")%></td>
</tr>
<tr>
<td> </td>
<td class="xg2"><%=left(rs("content"),30)%>...</td>
</tr>
</table></td>
</tr>
</table>
<%
rs.movenext
i=i+1
loop
%>
</td>
<%
rs.close
set rs=nothing
%>
</tr>
</table>
<%
rs1.close
set rs1=nothing
%>

...全文
121 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
always82 2008-11-21
  • 打赏
  • 举报
回复
非常感谢,可以取值了,就是页面乱了,我就是想循环取4个记录排成一列,现在3个正常显示,有一个跑到这列左面了,这样循环不对吗?下面是此处的循环语句
<%
set rs=server.createobject("adodb.recordset")
sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid <>"&NewsID&" and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
%>
<td width="341" valign="top">
<%
do while not rs.eof
%>
<table width="341" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="76"> <table width="66" height="51" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td bgcolor="#F0F0F0"> <table width="60" height="45" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="60" height="45" bgcolor="#FFFFFF"> <a href="uploadfile/ <%=rs("picname")%>" rel="lightbox" title="效果展示."> <img src="uploadfile/ <%=rs("picname")%>" alt="" width="60" height="45" border="0" /> </a> </td>
</tr> </table> </td>
</tr>
</table> </td>
<td width="253" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17"> <img src="img/index_24_1.gif" width="17" height="17"> </td>
<td height="23" class="xg1"> <%=rs("title")%> </td>
</tr>
<tr>
<td>  </td>
<td class="xg2"> <%=left(rs("content"),30)%>... </td>
</tr>
</table> </td>
</tr>
</table>
<%
rs.movenext
i=i+1
loop
%>
</td>
<%
rs.close
set rs=nothing
%>
</tr>
</table>
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
打错了
NewsID=rs("newsid")
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
找错了
NewsID=rs("newsid")
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
读取记录集中第一个列名的值
sql="select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
if not (rs.eob and rs.bof) then
NewsID=rs(0) //==NewsID=rs("title")
always82 2008-11-21
  • 打赏
  • 举报
回复
那个新加的rs(0)是什么意思啊?
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid not in (select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc) and checkked=1 order by bigclassid desc"
或者你改成

sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid not in (select top 1 newsid from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc) and checkked=1 order by bigclassid desc"
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
你这句SQL都是错的
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
你很多判断都不严谨,如果数据在为空的情况下,下面的肯定会出错的。
自己好好检查一下吧。
always82 2008-11-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhuyongzhao 的回复:]
sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid not in (select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc) and checkked=1 order by bigclassid desc"

晕,这句这样写呢
[/Quote]

应该是这句的问题吧,上面的都能执行呢,就这句以后的都不执行了,应该怎么写呢?
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
<%
set rsb=server.createobject("adodb.recordset")
sql="select bigclassid from bigclass order by bigclassid desc"
rsb.open sql,conn,1,1
bigclassid=Trim(rsb("bigclassid"))
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="249" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40">  </td>
<%set rs=server.createobject("adodb.recordset")
sql="select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
if not (rs.eob and rs.bof) then
NewsID=rs(0)

%>
<td width="209"> <table width="209" height="158" border="0" cellpadding="4" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td bgcolor="#F0F0F0">
<table width="201" height="150" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"> <a href="uploadfile/ <%=rs("picname")%>" rel="lightbox" title="效果展示."> <img src="uploadfile/ <%=rs("picname")%>" alt="" width="201" height="150" border="0" /> </a> </td>
</tr>
</table> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12"> </td>
</tr>
<tr>
<td height="23" bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#F6F6F6">
<tr>
<td bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17"> <img src="img/index_24_1.gif" width="17" height="17"> </td>
<td height="23" class="xg1"> <%=rs("title")%> </td>
</tr>
<tr>
<td>  </td>
<td class="xg2"> <%=left(rs("content"),20)%>... </td>
</tr>
</table> </td>
</tr>
</table> </td>
</tr>
</table> </td>
<%
end if
rs.close
set rs=nothing
%>
</tr>
</table> </td>
<%
set rs=server.createobject("adodb.recordset")
sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid <>"&NewsID&" and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
%>
<td width="341" valign="top">
<%
do while not rs.eof
%>
<table width="341" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="76"> <table width="66" height="51" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td bgcolor="#F0F0F0"> <table width="60" height="45" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="60" height="45" bgcolor="#FFFFFF"> <a href="uploadfile/ <%=rs("picname")%>" rel="lightbox" title="效果展示."> <img src="uploadfile/ <%=rs("picname")%>" alt="" width="60" height="45" border="0" /> </a> </td>
</tr>
</table> </td>
</tr>
</table> </td>
<td width="253" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17"> <img src="img/index_24_1.gif" width="17" height="17"> </td>
<td height="23" class="xg1"> <%=rs("title")%> </td>
</tr>
<tr>
<td>  </td>
<td class="xg2"> <%=left(rs("content"),30)%>... </td>
</tr>
</table> </td>
</tr>
</table>
<%
rs.movenext
i=i+1
loop
%>
</td>
<%
rs.close
set rs=nothing
%>
</tr>
</table>
<%
rs1.close
set rs1=nothing
%>


zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
你这上面SQL语句就有问题,肯定查询不出来

<%
set rsb=server.createobject("adodb.recordset")
sql="select bigclassid from bigclass order by bigclassid desc"
rsb.open sql,conn,1,1
bigclassid=Trim(rsb("bigclassid"))
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="249" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40">  </td>
<%set rs=server.createobject("adodb.recordset")
sql="select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
if not (rs.eob and rs.bof) then
NewsID=rs(0)

%>
<td width="209"> <table width="209" height="158" border="0" cellpadding="4" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td bgcolor="#F0F0F0">
<table width="201" height="150" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"> <a href="uploadfile/ <%=rs("picname")%>" rel="lightbox" title="效果展示."> <img src="uploadfile/ <%=rs("picname")%>" alt="" width="201" height="150" border="0" /> </a> </td>
</tr>
</table> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12"> </td>
</tr>
<tr>
<td height="23" bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#F6F6F6">
<tr>
<td bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17"> <img src="img/index_24_1.gif" width="17" height="17"> </td>
<td height="23" class="xg1"> <%=rs("title")%> </td>
</tr>
<tr>
<td>  </td>
<td class="xg2"> <%=left(rs("content"),20)%>... </td>
</tr>
</table> </td>
</tr>
</table> </td>
</tr>
</table> </td>
<%
end if
rs.close
set rs=nothing
%>
</tr>
</table> </td>
<%
set rs=server.createobject("adodb.recordset")
sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid <>"&NewsID&" and checkked=1 order by bigclassid desc"
rs.open sql,conn,1,1
%>
<td width="341" valign="top">
<%
do while not rs.eof
%>
<table width="341" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="76"> <table width="66" height="51" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#E6E6E6">
<tr>
<td bgcolor="#F0F0F0"> <table width="60" height="45" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="60" height="45" bgcolor="#FFFFFF"> <a href="uploadfile/ <%=rs("picname")%>" rel="lightbox" title="效果展示."> <img src="uploadfile/ <%=rs("picname")%>" alt="" width="60" height="45" border="0" /> </a> </td>
</tr>
</table> </td>
</tr>
</table> </td>
<td width="253" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17"> <img src="img/index_24_1.gif" width="17" height="17"> </td>
<td height="23" class="xg1"> <%=rs("title")%> </td>
</tr>
<tr>
<td>  </td>
<td class="xg2"> <%=left(rs("content"),30)%>... </td>
</tr>
</table> </td>
</tr>
</table>
<%
rs.movenext
i=i+1
loop
%>
</td>
<%
rs.close
set rs=nothing
%>
</tr>
</table>
<%
rs1.close
set rs1=nothing
%>
  • 打赏
  • 举报
回复
<%
set rsb=server.createobject("adodb.recordset")
sql="select bigclassid from bigclass order by bigclassid desc"
rsb.open sql,conn,1,1
bigclassid=Trim(rsb("bigclassid"))
%>
应该是你这部分出了问题
这部分有多条数据的话,你这么写就出大问题了!
zhuyongzhao 2008-11-21
  • 打赏
  • 举报
回复
sql="select top 4 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and newsid not in (select top 1 newsid,title,picname,content from news where typeid=2 and bigclassid="&bigclassid&" and checkked=1 order by bigclassid desc) and checkked=1 order by bigclassid desc"

晕,这句这样写呢

28,391

社区成员

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

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