if statement inside Do...while loop

liunx

Guest
Hi all,

just a quick one. I need to put an if statemnet within this piece of code to say that if there is no record (eof = true) then response.write ("no records found"). Each time i try and do this my nesting causes errors. Could someone please show me the correct way to embed it?

Thanx in advance!!

<form action="de_assign_specialism2.asp" method="POST">
<input type="hidden" name="id" value="<%=objrs("p_id")%>"><select name="spec" class="form">
<%
do while not objrs.eof
%>
<option value="<%response.write objrs("spu_id")%>"><%response.write objrs("spec_unit")%></option>
<%
objrs.movenext
loop
%>
</select>
<input type="Submit" name="" value="Submit" onClick="window.alert('The Specialism has been de-assigned')" style="background-color: #cccccc; font-weight: bold;">
</form>Never mind guys, got it working by putting this in directly after opening the recordset.

if (objRS.BOF and objRS.EOF) then
response.write "No records found"
response.end
End ifThat's what is fun about ASP. U think there is no light at the end of the tunnel. Then as u are about to give up or ask for help, you'll find the solution.

That's the nature of programming dude. Been there many times.

<!-- w --><a class="postlink" href="http://www.ex-designz.net">www.ex-designz.net</a><!-- w -->
Dexter
 
Back
Top