PDA

View Full Version : asp help



suantaik
15 Jan 2006, 07:22 PM
I need some help writing an IF statement for ASP. Perhaps an IF statement isn't the best choice here, I'm not really sure. Basically I am outputting a list of dealers for our website. Due to the design of the page, I need to change the table column properties in the last record so that it is different from the rows above it. Here's the code I have so far. I can't seem to get this to work though. It will output everything except the last record. How do I create a conditional output like this? Is an IF statement even the correct approach here?


<%
SQL_query = "SELECT * FROM dealerpage WHERE Region = 'North America' "
Set RS = MyConn.Execute(SQL_query)

IF NOT RS.EOF THEN
Response.Write "<tr><td><p align='left'><a href=' " & Rs("PageURL") & " '><b>" & rs("Country") & "</b></a></p></td></tr>"
RS.MoveNext
ELSE
Response.Write "<tr><td class='last'><p align='left'><a href=' " & Rs("PageURL") & " '><b>" & rs("Country") & "</b></a></p></td></tr>"
RS.MoveNext
END IF

%>

DanInManchester
18 Jan 2006, 09:10 AM
The problem with your code is that it will never fire the else if it is part of a loop.

The way I thought you could do this is to know how many records there are and then when you get the last record write out the alternate line.

something along the lines of :


intCurrentRecord = 1
while not rs.eof
If intCurrentRecord = intRecordCount then
' this is the last record
else

end if
intCurrentRecord = intCurrentRecord + 1
rs.movenext
wend