If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP returning SQL data help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-15-04, 12:16
spacdude spacdude is offline
Registered User
 
Join Date: Sep 2004
Location: UK
Posts: 15
Question ASP returning SQL data help

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
Reply With Quote
  #2 (permalink)  
Old 09-15-04, 13:31
RBARAER RBARAER is offline
Registered User
 
Join Date: Aug 2004
Location: France
Posts: 754
Hello,

Could you send all your asp code concerning this matter, please ? It will help !

Regards,

RBARAER
Reply With Quote
  #3 (permalink)  
Old 09-16-04, 04:51
spacdude spacdude is offline
Registered User
 
Join Date: Sep 2004
Location: UK
Posts: 15
I got it sorted using a "Do Until statement" thanks anyway.
Reply With Quote
  #4 (permalink)  
Old 09-16-04, 12:14
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
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.
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
  #5 (permalink)  
Old 09-17-04, 04:41
spacdude spacdude is offline
Registered User
 
Join Date: Sep 2004
Location: UK
Posts: 15
At the moment i am using an If statement like this:

<%if objRecordset.EOF then Response.Write("No information was found in our databases for the record you have entered") %>

<% Do Until objRecordset.EOF %>
<% Response.Write "<TR><TD>The record that the database has returned is " & objRecordset("TicketNumber") &"</TD></TR>" %>

<% objRecordset.MoveNext %>
<% Loop %>
<%objConn.Close
set objConn=Nothing
%>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On