Solved

best way of writing ---

Posted on 2011-03-12
9
277 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
  • 4
  • 3
  • 2
9 Comments
 
LVL 11

Expert Comment

by:psantiangeli
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:
psantiangeli earned 250 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
 
LVL 23

Expert Comment

by:adilkhan
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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:psantiangeli
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:adilkhan
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:psantiangeli
ID: 35131490
adilkhan:
Request("ID") is not from recordset but from http request...
0
 
LVL 23

Assisted Solution

by:adilkhan
adilkhan earned 250 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to dynamically set the form action using jQuery.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now