Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop Errors

Status
Not open for further replies.

discusmania

IS-IT--Management
Oct 24, 2000
158
AP

Hello...
1. I encounter error when i run this code. The error is:

error '80020009'
Exception occurred.
/hr/dbs/news.asp, line 28

2. I want the program to get the number of records in mytable then pass the value to a variable. How to do that?

Can someone please review my code

<% dim i
'dim reccount
'reccount=SELECT count(*) from news
response.write reccount
for i=0 to 5
if objRec(&quot;date&quot;)=(date) then %>
<div align=&quot;left&quot;>
<table border=&quot;0&quot; width=&quot;80%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot; bgcolor=&quot;#FFFFFF&quot;>
<tr>
<td width=&quot;100%&quot; bgcolor=&quot;#FF9900&quot;><center><font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#333399&quot;><b><%=objRec(&quot;headLine&quot;)%></b></center></font></td>
</tr>
<tr>
<td width=&quot;100%&quot; bgcolor=&quot;#FFFF66&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;><div align=&quot;justify&quot;><%=objRec(&quot;newsBody&quot;)%></div></font></td>
</tr>
<!-- <tr>
<td width=&quot;100%&quot;><font color=&quot;#800000&quot; face=&quot;Arial&quot; size=&quot;2&quot;>Updated by :<a href=&quot;mailto:<%=objRec(&quot;mail&quot;)%>&quot;><%=objRec(&quot;writer&quot;)%></a><br>
</font><font color=&quot;#800000&quot; size=&quot;1&quot; face=&quot;Arial&quot;>
Date :<%=objRec(&quot;date&quot;)%></font>
</font>
</td>
</tr> -->
</table>
</div>
<p>
<% end if

objRec.MoveNext

next%>
 
Firstly, there's an easy way to count your records:

Code:
reccount = objRec.RecordCount

Now for the hard part, what are you using the loop for? It seems you're always checking the first 6 records, regardless of the number of records returned. That could be your problem.

Choo Khor
choo.khor@intelebill.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top