ASP+Access判断记录集为空.
<%setrs=server.CreateObject("adodb.recordset")rs.Open"select*fromb1orderbyiddesc",con...
<%
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from b1 order by id desc ",conn%> <%Do Until rs.eof%><%=rs("username")%><%=rs("mail")%><%rs.movenext
loop
rs.close
conn.close
set rs=nothing
set conn=nothing
%> 当username,mail其中一个字段为空,就不能正常显示了.请问高手怎么解决?在本代码上怎么改? 展开
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from b1 order by id desc ",conn%> <%Do Until rs.eof%><%=rs("username")%><%=rs("mail")%><%rs.movenext
loop
rs.close
conn.close
set rs=nothing
set conn=nothing
%> 当username,mail其中一个字段为空,就不能正常显示了.请问高手怎么解决?在本代码上怎么改? 展开
2013-07-19
展开全部
在sql语句中判断username和mail的值是否为空,为空的就不读去他,代码如下set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from b1 where username<>"" and mail<>"" order by id desc ",conn,1,1
Do Until rs.eof
response.write(rs("username"))
response.Write(rs("mail"))
rs.movenext
loop
rs.close
conn.close
rs.Open "select * from b1 where username<>"" and mail<>"" order by id desc ",conn,1,1
Do Until rs.eof
response.write(rs("username"))
response.Write(rs("mail"))
rs.movenext
loop
rs.close
conn.close
2013-07-19
展开全部
<%
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from b1 order by id desc ",connDo while not rs.eof%><%=rs("username")%><%=rs("mail")%><%rs.movenext
loop
rs.close
conn.close
set rs=nothing
set conn=nothing
%> 字段为空的话 你可以做个判断 显示为别的
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from b1 order by id desc ",connDo while not rs.eof%><%=rs("username")%><%=rs("mail")%><%rs.movenext
loop
rs.close
conn.close
set rs=nothing
set conn=nothing
%> 字段为空的话 你可以做个判断 显示为别的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-19
展开全部
加入if判断记录集是否为空 如下:rs.Open "select * from b1 order by id desc ",connif rs.eof thenresponse.write “赞无记录"elseDo Until rs.eof%><%=rs("username")%><%=rs("mail")%><%rs.movenext
loopend if
rs.close
conn.close
set rs=nothing
set conn=nothing
loopend if
rs.close
conn.close
set rs=nothing
set conn=nothing
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-19
展开全部
怎么个不正常法?截个图看看呀。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询