Solved

best way of writing ---

Posted on 2011-03-12
9
278 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

895 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

12 Experts available now in Live!

Get 1:1 Help Now