PDA

View Full Version : Displaying ASP errors


forgodsake8
04-12-2005, 11:21 AM
Hi,
I'm trying to set up a staff page, and Ive got it to work outputting all the photos with staff details such Name, Dept and Extension Num.
I wanted it to I could have three pictures per row horizontally across the page.
The only way I could get it to work like this was using the following code:


<table width="90%" align="left">
<%
dim ctr
ctr=1
DO WHILE NOT temp.EOF
IF ctr = 1 THEN
response.write "<tr>"
END IF
%>

<td align=center>
<img src="/Pictures/<% Response.write temp("Picture")%>" width=200 height=150><br>
<% Response.write temp("Name")%> <br> <% Response.write temp("Job_Title")%><br>
<% Response.write temp("Department")%><br><% Response.write temp("Ext")%>
</td>

<%
IF ctr = 3 THEN
reponse.write "</tr>"
ctr = 1
ELSE
ctr = ctr + 1
END IF

temp.MoveNext
Loop
%>
</table>



The problem I get though is if say I have 5 photos...it loops through the first three fine...but when it loops through the next three....because there are only five photos and not six...it coming up with a not at EOF error....because there's nothing to fill the last record:

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/accounts.asp, line 0

I know this is because its running through the output of the photographs and hitting the last record of photo output and there's nothing to output...but I can't see any other way of coding it so it outputs the page with three photos per row.

Any ideas?!!?
Thanks.

glenngv
04-12-2005, 12:15 PM
That is because you have 3 movenext statements within the loop. You don't have to do that to have 3 columns per row. You just need a counter to keep track of the columns.

<%
dim ctr
ctr = 1
DO WHILE NOT temp.EOF
if ctr = 1 then
response.write "<tr>"
end if
%>
<td align=center>
<img src="/Pictures/<% Response.write temp("Picture")%>" width=200 height=150><br>
<% Response.write temp("Name")%> <br> <% Response.write temp("Job_Title")%><br>
<% Response.write temp("Department")%><br><% Response.write temp("Ext")%>
</td>
<%
if ctr = 3 then
response.write "</tr>"
ctr = 1 'reset
else
ctr = ctr + 1
end if
temp.MoveNext
Loop
%>

forgodsake8
04-13-2005, 04:44 PM
Ive made the changes as you suggested as follows:

[code]
<table width="90%" align="left">
<%
dim ctr
ctr=1

DO WHILE NOT temp.EOF
IF ctr = 1 THEN
response.write "<tr>"
END IF
%>
<td align=center>
<img src="/Pictures/<% Response.write temp("Picture")%>" width=200 height=150><br>
<% Response.write temp("Name")%> <br> <% Response.write temp("Job_Title")%><br>
<% Response.write temp("Department")%><br><% Response.write temp("Ext")%>
</td>
<%
IF ctr = 3 THEN
reponse.write "</tr>"
ctr = 1
ELSE
ctr = ctr + 1
END IF

temp.MoveNext
Loop

%>
</table>
[/code>

It outputs the first three pictures, but then comes up with error Microsoft

VBScript runtime error '800a01a8'
Object required: ''

/indexTest.asp, line 52

It seems like it doesn't like the loop....but I can't think how to change it.
Can anyone shed some light?
Thanks.

miranda
04-13-2005, 08:20 PM
Which line does the error point to? generally that error is telling you that an object does not exist, perhaps you closed and released the reference to the object somewhere before you were done using it.

oracleguy
04-14-2005, 03:58 AM
I bet it is this:

<table width="90%" align="left">
<%
dim ctr
ctr=1

DO WHILE NOT temp.EOF
IF ctr = 1 THEN
response.write "<tr>"
END IF
%>
<td align=center>
<img src="/Pictures/<% Response.write temp("Picture")%>" width=200 height=150><br>
<% Response.write temp("Name")%> <br> <% Response.write temp("Job_Title")%><br>
<% Response.write temp("Department")%><br><% Response.write temp("Ext")%>
</td>
<%
IF ctr = 3 THEN
reponse.write "</tr>"
ctr = 1
ELSE
ctr = ctr + 1
END IF

temp.MoveNext
Loop

%>
</table>


You mis-spelled 'response' :)

forgodsake8
04-14-2005, 09:51 AM
Ah...Oracleguy you're right!
Thanks for that
Glenngv, thanks for the code also! :D