Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

best way of writing ---

Posted on 2011-03-12
9
Medium Priority
?
289 Views
Last Modified: 2012-05-11
I have the following code on my asp vbscript page -

              <%if (descript.Fields.Item("JBATitle").Value) <> "" then%> <%=(descript.Fields.Item("JBATitle").Value)%> <%End if%>vacancy application

However it appears to be failing as I keep getting the following error --

File Name: /logn.asp
Line Number: 280
Description: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

Where line 280 is

<%if (descript.Fields.Item("JBATitle").Value) <> "" then%> <%=(descript.Fields.Item("JBATitle").Value)%> <%End if%>vacancy application


Is there a better way of writing the code?

Thank you
0
Comment
Question by:garethtnash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 11

Expert Comment

by:Paolo Santiangeli
ID: 35116921
hi,
seems your query does not return records....

0
 

Author Comment

by:garethtnash
ID: 35116936
Yes so IF statement  should not show anything in that case?
0
 
LVL 11

Accepted Solution

by:
Paolo Santiangeli earned 1000 total points
ID: 35116971
you have to check BOF and EOF:

if rs.eof and rs.bof then
 response.write("empty")
end if

have a look here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_23394546.html
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 23

Expert Comment

by:Saqib Khan
ID: 35117498
That is correct EOF check is important.


After you do Rs.Open and whenever you try to access fields from table do this...


<%
  if NOT descript.Eof Then
%>

<%if (descript.Fields.Item("JBATitle").Value) <> "" then%> <%=(descript.Fields.Item("JBATitle").Value)%> <%End if%>vacancy application


<%


 Else

           Response.write "Nothing Found"

 End if

 

%>
0
 

Author Comment

by:garethtnash
ID: 35121682
Thanks, I have put that in place, however I'm still getting errors, is there anyway of the recordset having data when it is written, but not once it tries to write contents?

 is there a way of writing this instead or as well -

<%IF Request("ID") <> "" AND Not descript.EOF Or Not descript.BOF then Reponse.Redirect("xxx")%>

thanks
0
 
LVL 11

Expert Comment

by:Paolo Santiangeli
ID: 35123025
mmm EOF an BOF are both true when recordset is empty so youhave to check AND condition
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 35125619
> <%IF Request("ID") <> "" AND Not descript.EOF Or Not descript.BOF then Reponse.Redirect("xxx")%>

NO, EOF or BOF check should be performed before you access ANY Data field.

why dont you do like this

if Not Rs.eof Then  
   varA = Rs("ID") ' some variable
end if


if varA = ""  Then
   ' code
end if
0
 
LVL 11

Expert Comment

by:Paolo Santiangeli
ID: 35131490
adilkhan:
Request("ID") is not from recordset but from http request...
0
 
LVL 23

Assisted Solution

by:Saqib Khan
Saqib Khan earned 1000 total points
ID: 35131520
yes..that you can do. however i would recommend like this..


IF Request("ID") <> "" Then

 If NOT Rs.Eof Then ' We have some Data

 Else  ' No Data Found

 End if


End if
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question