Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Error when No records found
Old 08-05-2005, 05:32 AM Error when No records found
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Hi there,
I have the below sub running in my asp page, which works fine until null records or returned to the resultset.

How do I prevent this.

Code:
sub getExperience(idnum)
     Set RSf = Server.CreateObject("ADODB.Recordset") 
    strSQL = "SELECT * FROM Experience where expertid=" & idnum
    RSf.Open strSQL, Conn 
    RSf.MoveFirst 
    do while not RSf.EOF
	    response.write("<div>&nbsp;</div>")
	    response.write("<div class='moreheader'>")
		  response.write(RSf("experience_date"))
		response.write("</div>")
		 response.write("<div class='morebody'>")
		  response.write(RSf("experience"))
		response.write("</div>")
	RSf.movenext
	loop
   end sub
cheers

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 08-05-2005, 09:15 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
if not rsf.eof or not rsf.bof then 
' do this
end if
or if you don't like negative booleans

Code:
if rsf.eof or rsf.bof then 
' do this (no records)
else
' do this with records
end if
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-05-2005, 09:15 AM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
Try changing your 'do while' loop to a simple 'while' loop.

while not RSf.EOF
...


With a 'do while' loop, the code is executed once, and then the condition (RSf.EOF) is checked.
in a 'while' loop, the condition is checked before the code is executed.
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 08-05-2005, 09:19 AM
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
oh lol. Easy when you see how.
Thanks alot.
Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Reply     « Reply to Error when No records found
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23553 seconds with 12 queries