| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1050 人关注过本帖
标题:do while语句出错
只看楼主 加入收藏
ywxhqt2005
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-6-6
收藏
得分:0 
是啊,怎么办?我对do while 语句不是很了解,是刚接触ASP不久的那种
2007-06-06 17:50
ywxhqt2005
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-6-6
收藏
得分:0 
哪位高手帮帮忙啊,在此先谢了!
2007-06-06 17:52
rtc
Rank: 2
等 级:新手上路
威 望:4
帖 子:590
专家分:0
注 册:2007-6-6
收藏
得分:0 

换成
for ..next循环..

2007-06-06 17:53
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
在DIM F后面加上
F=1 试试
2007-06-06 18:35
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
收藏
得分:0 

[QUOTE]<!--#include file="oConn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>永州职业技术学院成教部欢迎您!</title>
<link href="cjb.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="990" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<!--#include file="top.asp"--></td></tr>
<tr>
<td><table width="990" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="1" valign="top" bgcolor="#004292"></td>
<td rowspan="4" width="15">&nbsp;</td>
<td><table width="990" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="318" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="182" height="4">&nbsp;</td>
</tr>
<tr>
<td width="182" height="28"><img src="images/gbl2.gif" width="318" height="42" /></td>
</tr>
<tr>
<td><table width="318" border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<%
set oRs=server.createobject("adodb.recordset")
sSql="select top 8 * from news where cataid='公布栏' order by id desc "
oRs.open sSql,oConn,1,1
if oRs.eof then
response.Write "数据库中无此记录!"
else
do while not oRs.eof
%>
<tr>
<td width="25" height="21" align="center" valign="middle"><img src="images/wjj.gif" width="14" height="9" /></td>
<td height="21"><a href="xyxw_view.asp?id=<%=oRs("id")%>" class="ttblue" title=<%=oRs("title")%>>
<%if len(oRs("title"))>18 then%>
<%=left(oRs("title"),18)%>…
<%else%>
<%=oRs("title")%>
<%end if%>
</a>
<%if len(title)<15 then%>
<%=oRs("addtime")%>
<%end if%>
</td>
</tr>
<%
oRs.movenext
loop
oRs.close
end if
%>
</table></td>
</tr>
</table></td>
<td><table width="297" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="4">&nbsp;</td>
</tr>
<tr>
<td width="297"><img src="images/zsxx2.gif" width="297" height="42" /></td>
</tr>
<tr>
<td><table width="" border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<tr>
<td><table width="297" border="0" cellspacing="0" cellpadding="0">
<%
set oRs=server.createobject("adodb.recordset")
sSql="select top 8 * from news where cataid='招生信息' order by id desc "
oRs.open sSql,oConn,1,1
if oRs.eof then
response.Write "数据库中无此记录!"
else
do while not oRs.eof
%>
<tr>
<td width="25" height="21" align="center" valign="middle"><img src="images/wjj.gif" width="14" height="9" /></td>
<td height="21"><a href="xyxw_view.asp?id=<%=oRs("id")%>"class="ttblue" title=<%=oRs("title")%>>
<%if len(oRs("title"))>18 then%>
<%=left(oRs("title"),18)%>…
<%else%>
<%=oRs("title")%>
<%end if%>
</a>
<%if len(title)<15 then%>
<%=oRs("addtime")%>
<%end if%>
</td>
</tr>
<%
oRs.movenext
loop
oRs.close
end if
%>
</table></td>
</tr>
</table></td>
<td><table width="198" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="4">&nbsp;</td>
</tr>
<tr>
<td><img src="images/cjcx1.gif" width="198" height="63" /></td>
</tr>
<tr>
<td><table width="198" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="4">&nbsp;</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="42" height="20"><img src="images/xh.gif" width="35" height="15"></td>
<td width="156"><INPUT name=xsxh class="tt" id=xsxh
size=16 maxLength=16></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="42" height="20"><img src="images/xm.gif" width="35" height="15"></td>
<td width="156"><INPUT name=xsxm class="tt" id=xsxm4 size=16></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/tj.gif" width="26" height="12" align="right"></td>
<td width="4">&nbsp;</td>
<td><img src="images/cz.gif" width="26" height="12"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="990" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="387"><table width="318" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="4">&nbsp;</td>
</tr>
<tr>
<td><img src="images/zkkx2.gif" width="318" height="47" /></td>
</tr>
<tr>
<td><table width="" border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<tr>
<td><table width="318" border="0" cellspacing="0" cellpadding="0">
<%
set oRs=server.createobject("adodb.recordset")
sSql="select top 8 * from news where cataid='自考快讯' order by id desc "
oRs.open sSql,oConn,1,1
if oRs.eof then
response.Write "数据库中无此记录!"
else
do while not oRs.eof
%>

<tr>
<td width="25" height="21" align="center" valign="middle"><img src="images/wjj.gif" width="14" height="9" /></td>
<td height="21"><a href="xyxw_view.asp?id=<%=oRs("id")%>"class="ttblue" title=<%=oRs("title")%>>
<%if len(oRs("title"))>18 then%>
<%=left(oRs("title"),18)%>…
<%else%>
<%=oRs("title")%>
<%end if%>
</a>
<%if len(title)<15 then%>
<%=oRs("addtime")%>
<%end if%>
</td>
</tr>
<%
oRs.movenext
loop
oRs.close
end if
%>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="361"><table width="297" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><img src="images/cjkx2.gif" width="297" height="47" /></td>
</tr>
<tr>
<td><table width="182" border="0" cellspacing="0" cellpadding="0" bgcolor="#F2F2F2">
<tr>
<td><table width="297" border="0" cellspacing="0" cellpadding="0">
<%
set oRs=server.createobject("adodb.recordset")
sSql="select top 8 * from news where cataid='成教快讯' order by id desc "
oRs.open sSql,oConn,1,1
if oRs.eof then
response.Write "数据库中无此记录!"
else
do while not oRs.eof
%>
<tr>
<td width="25" height="21" align="center" valign="middle"><img src="images/wjj.gif" width="14" height="9" align="center"/></td>
<td height="21"><a href="xyxw_view.asp?id=<%=oRs("id")%>"class="ttblue" title=<%=oRs("title")%>>
<%if len(oRs("title"))>18 then%>
<%=left(oRs("title"),18)%>…
<%else%>
<%=oRs("title")%>
<%end if%>
</a>
<%if len(title)<15 then%>
<%=oRs("addtime")%>
<%end if%>
</td>
</tr>
<%
oRs.movenext
loop
oRs.close
end if
%>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="242"><table width="198" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/lqcx1.gif" width="197" height="69"></td>
</tr>
<tr>
<td><a href="#"><img src="images/11.gif" width="198" height="98" border="0"></a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td width="1" valign="top" bgcolor="#004292"></td>
</tr>
</tr>
</table>
</table>
<!--#include file="bottom.asp"-->
</body>
</html>[/QUOTE]

这样试一下.

2007-06-07 09:50
guyer
Rank: 2
等 级:新手上路
威 望:5
帖 子:451
专家分:0
注 册:2007-1-19
收藏
得分:0 
<%
set oRs=server.createobject("adodb.recordset")
sSql="select top 8 * from news where cataid='公布栏' order by id desc "
你在这里只提取了8条记录, 但是循环却是9条记录
oRs.open sSql,oConn,1,1%>
<%dim e
e=1
do while not oRs.eof
去掉 and e<10
if len(oRs("title"))>18 then
title=left(oRs("title"),18)+"…"
else
title=oRs("title")
end if
if len(title)<15 then
addtime=oRs("addtime")
else
addtime=""
end if
%>
<tr>
<td width="25" height="21" align="center" valign="middle"><img src="images/wjj.gif" width="14" height="9" /></td>
<td height="21"><a href="xyxw_view.asp?id=<%=oRs("id")%>"class="ttblue" title=<%=oRs("title")%>><%=title%></a><%=addtime%></td>
</tr>
<%e=e+1
if e>=10 then
exit do
end if
oRs.movenext
loop
oRs.close

http://www./
2007-06-07 11:44
快速回复:do while语句出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016956 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved