我需要在使用
实际移动到记录集之前测试记录集是否有下一个元素 Recordset.MoveNext
编辑:
我有一些记录,这些记录是用图像分隔的,但是当涉及到最后一条记录时,不需要图像,为什么我需要测试记录是否有下一个记录,或者它是最后一个记录
<% while not Recordset.EOF
ItemId = Recordset.fields("ITEM_ID")
itemView= ItemId &" "& Recordset.fields("SHORT_DESC")
%>
<tr>
<td style="width:240px !important; word-break: break-all;">
<a href="view_work_item.asp?item_id=<%=ItemId%>&hometoURL=<% =Server.URLEncode(navpath & "/de/ticket/liste_ticket_pl.asp")%>" >
<%=titemView%></a></td>
<td background="../../images/white-dot.gif" ><img src="../../images/white-dot.gif" width="1" height="8" ></td>
<td style="width:240px !important; word-break: break-all;"><%=i%></td>
</tr>
//test here if it's the last element don't show this image
<tr>
<td align="center" class="subnav" colspan="3" height="1"><img src="../../images/white-dot.gif" width="100%" height="1"/></td>
</tr>
<% Recordset.MoveNext
wend %>
答案 0 :(得分:1)
使用Recordset.EOF或BOF开始
if not Recordset.EOF then
Recordset.MoveNext
end
要解决您的问题,请尝试此操作。
<% while not Recordset.EOF
ItemId = Recordset.fields("ITEM_ID")
itemView= ItemId &" "& Recordset.fields("SHORT_DESC")
Recordset.MoveNext
%>
<tr>
<td style="width:240px !important; word-break: break-all;">
<a href="view_work_item.asp?item_id=<%=ItemId%>&hometoURL=<% =Server.URLEncode(navpath & "/de/ticket/liste_ticket_pl.asp")%>" >
<%=titemView%></a></td>
<td background="../../images/white-dot.gif" ><img src="../../images/white-dot.gif" width="1" height="8" ></td>
<td style="width:240px !important; word-break: break-all;"><%=i%></td>
</tr>
<% if not Recordset.EOF then %>
//test here if it's the last element don't show this image
<%end%>
<tr>
<td align="center" class="subnav" colspan="3" height="1"><img src="../../images/white-dot.gif" width="100%" height="1"/></td>
</tr>
<% wend %>
答案 1 :(得分:0)
您可以在HTML之前移动Recordset.MoveNext
语句并在那里进行测试。您已经保存了所需的记录集值,因此提前推进它不会改变任何内容。如果你只有一个记录,我认为这会更好,因为它不会显示图像分隔符。
If Not Recordset.EOF Then
Do While True
ItemId = Recordset.fields("ITEM_ID")
itemView= ItemId &" "& Recordset.fields("SHORT_DESC")
Recordset.MoveNext
If Recordset.EOF Then Exit Do
' HTML code here
Loop
End If