View Single Post
Old 04-12-2005, 01:40 AM   #1 (permalink)
loumanley
Registered User
 
Join Date: Apr 2005
Posts: 1
loumanley is on a distinguished road
Displaying ASP help...

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:

Code:
<html>
<head>

<%
dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("staff.mdb") & ";"
%>

</head>

<!--#include virtual="/header.inc" -->
<table width="90%" border="0" cellspacing="4" cellpadding="2" align="center">
  <tr valign="top"> 
    <td width="150" align="center" rowspan="5"><br>
    </td>
    <td colspan="3" bgcolor="#CCCCCC">      <p>Departmental Photo's</p></td>
  </tr>
  <tr> 
    <td height="134" colspan="3">      <p>Some Bumpf<p>

</p>

<%
dim mySQL
mySQL = "SELECT * FROM staff WHERE department LIKE '%Acc%' ORDER BY name ASC"
dim temp
Set temp = Server.CreateObject("ADODB.Recordset")
temp.Open mySQL, conn
%>

<table width="90%" align="left">
<% DO WHILE NOT temp.EOF 
%>
<tr>
<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>
<% temp.MoveNext %>
<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>
<% temp.MoveNext %>
<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>

<%
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.
loumanley is offline   Reply With Quote