ASP逻辑问题

来源:百度知道 编辑:UC知道 时间:2024/09/26 02:20:52
<%
set rs = Server.CreateObject("ADODB.recordset")
swl = "select *from radio_link"
rs.open swl,conn,1,3
第一个 If (rs.bof and rs.eof)then
Response.Write("没有填写内容!")
Else
Dim i
For i=1 to rs.recordcount
%>
<li><a href="<%=rs("address")%>"><%=rs("name")%></a>|</li>
<%
rs.movenext
If (rs.eof)then
Exit For
End If
Next
End If

因为第一个for的时候不断使用rs.movenext把指针已经移到了数据库的最下方,所以第二个if会不正常,解决这个问题很简单,你只需要使用一次rs.movefirst把指针移到数据库第一条就行了