murgeltd
06-02-2006, 01:47 PM
This scenario will probably not occur but if it does how can I stop the follow error from occuring.
I have a page that display the first 3 records from a table in date order. I have now added a condition on the SQL statement to say:
SELECT * FROM news WHERE newsLive = '0' ORDER BY newsPostedDate DESC
There is only one record that has newsLive value of 0 and as such it displays that record then the following error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
I know it's because I have code that displays the first three records but there is only one. How do I test for smaller than 3 records without user getting above error.
If it helps my snipet of code is below
<% for i = 1 to 3 %>
<tr>
<td width="30%" valign="top">
<a href="newsDetails.asp?newsID=<%=(rs.Fields.Item("newsID").Value)%>"><% response.Write(rs("newsSubject")) %></a></br>
<p><% response.Write(rs("newsPostedDate")) %></p>
<!-- At the moment it creates new table for each entry - but need to create new td for each entry -->
</td>
</tr>
<%
rs.MoveNext
Next
%>
Cheers
I have a page that display the first 3 records from a table in date order. I have now added a condition on the SQL statement to say:
SELECT * FROM news WHERE newsLive = '0' ORDER BY newsPostedDate DESC
There is only one record that has newsLive value of 0 and as such it displays that record then the following error:
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
I know it's because I have code that displays the first three records but there is only one. How do I test for smaller than 3 records without user getting above error.
If it helps my snipet of code is below
<% for i = 1 to 3 %>
<tr>
<td width="30%" valign="top">
<a href="newsDetails.asp?newsID=<%=(rs.Fields.Item("newsID").Value)%>"><% response.Write(rs("newsSubject")) %></a></br>
<p><% response.Write(rs("newsPostedDate")) %></p>
<!-- At the moment it creates new table for each entry - but need to create new td for each entry -->
</td>
</tr>
<%
rs.MoveNext
Next
%>
Cheers