Hi, I have written some ASP code that selects some records from a SQL database according to a criteria, if no information is found in the database then it sees there is an End Of File in the object record set and prints the line below:
<%if objRecordset.EOF then Response.Write("No information was found for the record you have entered") %>
My problem is that if no records are found it still tries to print the information that it is looking for and cannot find and thus throws an exception. The code for that is below:
<Table Border="1" BGCOLOR="white">
<% Response.Write "<TR><TD>The date for that record is " & objRecordset("DateTime") & "<br></TD></TR>" %>
I have tried IF else statements to get around this but im not sure what criteria I should use?
If anyone has any ideas it would be most helpful
Well, you can indeed have "a loop that executes zero times," but it seems to me that you should have an if..then..else structure. If you determine that there are no records, then "that's it." else... print them.