asp 读取数据库为空时的判断问题。
无论库里该分类下是否有数据,读出来都为“尚未添加候选人,请通过后台添加”。错误在哪?<!--#includefile="conn.asp"--><%fenlei=requ...
无论库里该分类下是否有数据,读出来都为“尚未添加候选人,请通过后台添加”。错误在哪?
<!--#include file="conn.asp"-->
<%
fenlei=request("fenlei")
set rs = server.CreateObject("adodb.recordset")
rs.open "select id,title,point from menber where fenlei="&fenlei&" order by point desc",conn,1,1
countpoint = 0
while not rs.eof
countpoint = countpoint + rs.fields("point")
rs.movenext
wend
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title><%=request("fenlei")%></title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="800" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"> </td>
</tr>
<tr>
<td align="center"> </td>
</tr>
<tr>
<td align="center"><!--#include file="top.asp"--></td>
</tr>
<table width="800" border="0" align="center" bgcolor="#9c1c18">
<tr>
<td width="800" height="1688" colspan="9" valign="top" bgcolor="#9c1c18" alt=""><table width="800" border="0" align="center" bgcolor="#9c1c18">
<tr>
<td height="17"><table width=800 border=0 cellpadding=0 cellspacing=0 align="center" bgcolor="#FFF2BB">
<tr><td>
<table width=780 border=0 cellpadding=5 cellspacing=0 align="center" bgcolor="#FFF2BB">
<tr><td height='8'></td></tr>
<tr><td class=fl> </td></tr>
<tr><td class=f14></td></tr>
</table>
<tr><td>
<table width=360 border=0 cellpadding=0 cellspacing=0 bgcolor=#b18a02 align="center">
<tr><td>
<table width=800 border=0 cellpadding=3 cellspacing=1 align="center">
<tr bgcolor=#f9dc34 align=center>
<td class=f14 colspan='4' align=left style='padding-left:5px'><%=request("fenlei")%>最新投票结果:</td>
</tr>
<%
if not rs.eof then
%>
<tr bgcolor=#ffffff align=center>
<td class=f14 width=27>序号</td>
<td class=f14 width=143>姓名</td>
<td class=f14 width=55>票数</td></tr>
<%
loopindex = 1
rs.movefirst
while not rs.eof%>
<tr bgcolor=#ffffff align=center><td width=27 class=f14><%=loopindex%></td>
<td width=143 class=f14><a href='show.asp?id=<%=rs.fields("id")%>' title="<%=rs.fields("title")%>" target="_blank" style="text-decoration: none;"><%=rs.fields("title")%></a></td>
<td class=f14 width=55 align=left><font color=#0262cd><%=rs.fields("point")%></font></td>
</tr>
<%
loopindex = loopindex + 1
rs.movenext
wend
else
%>
<tr bgcolor="#ffffff">
<td width="100%" align="center">尚未添加候选人,请通过后台添加!</td>
</tr>
<% end if
%>
</table>
</td></tr>
</table>
</td></tr>
<tr><td>
</td></tr>
<tr height="30"><td class=fl align="center"><p><a href="#" onClick="location.reload()">请您刷新以获得最新的统计结果!</a>
</p>
<p> </p></td></tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>
我这个判断语句在其他页面用都没问题,就这个页面出错,郁闷.
谢谢1楼回答,如果不加判断语句,<% if not rs.eof then %>,那么有数据的分类显示正常。无分类出无数据的提示。 展开
<!--#include file="conn.asp"-->
<%
fenlei=request("fenlei")
set rs = server.CreateObject("adodb.recordset")
rs.open "select id,title,point from menber where fenlei="&fenlei&" order by point desc",conn,1,1
countpoint = 0
while not rs.eof
countpoint = countpoint + rs.fields("point")
rs.movenext
wend
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title><%=request("fenlei")%></title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="800" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"> </td>
</tr>
<tr>
<td align="center"> </td>
</tr>
<tr>
<td align="center"><!--#include file="top.asp"--></td>
</tr>
<table width="800" border="0" align="center" bgcolor="#9c1c18">
<tr>
<td width="800" height="1688" colspan="9" valign="top" bgcolor="#9c1c18" alt=""><table width="800" border="0" align="center" bgcolor="#9c1c18">
<tr>
<td height="17"><table width=800 border=0 cellpadding=0 cellspacing=0 align="center" bgcolor="#FFF2BB">
<tr><td>
<table width=780 border=0 cellpadding=5 cellspacing=0 align="center" bgcolor="#FFF2BB">
<tr><td height='8'></td></tr>
<tr><td class=fl> </td></tr>
<tr><td class=f14></td></tr>
</table>
<tr><td>
<table width=360 border=0 cellpadding=0 cellspacing=0 bgcolor=#b18a02 align="center">
<tr><td>
<table width=800 border=0 cellpadding=3 cellspacing=1 align="center">
<tr bgcolor=#f9dc34 align=center>
<td class=f14 colspan='4' align=left style='padding-left:5px'><%=request("fenlei")%>最新投票结果:</td>
</tr>
<%
if not rs.eof then
%>
<tr bgcolor=#ffffff align=center>
<td class=f14 width=27>序号</td>
<td class=f14 width=143>姓名</td>
<td class=f14 width=55>票数</td></tr>
<%
loopindex = 1
rs.movefirst
while not rs.eof%>
<tr bgcolor=#ffffff align=center><td width=27 class=f14><%=loopindex%></td>
<td width=143 class=f14><a href='show.asp?id=<%=rs.fields("id")%>' title="<%=rs.fields("title")%>" target="_blank" style="text-decoration: none;"><%=rs.fields("title")%></a></td>
<td class=f14 width=55 align=left><font color=#0262cd><%=rs.fields("point")%></font></td>
</tr>
<%
loopindex = loopindex + 1
rs.movenext
wend
else
%>
<tr bgcolor="#ffffff">
<td width="100%" align="center">尚未添加候选人,请通过后台添加!</td>
</tr>
<% end if
%>
</table>
</td></tr>
</table>
</td></tr>
<tr><td>
</td></tr>
<tr height="30"><td class=fl align="center"><p><a href="#" onClick="location.reload()">请您刷新以获得最新的统计结果!</a>
</p>
<p> </p></td></tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>
我这个判断语句在其他页面用都没问题,就这个页面出错,郁闷.
谢谢1楼回答,如果不加判断语句,<% if not rs.eof then %>,那么有数据的分类显示正常。无分类出无数据的提示。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询