Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CFABORT is not stopping my cfm page.

Posted on 2006-04-06
4
Medium Priority
?
392 Views
Last Modified: 2013-12-24
I am trying to use <CFABORT> to exit a cf page when the CFQUERY in the page finds no records.
I want to do this so the CFLOOP after the CFQUERY does not continue.

The problem is that the page continues to process.  I need the  to stop the process and give the error message to the user.
Here is the part of my code that is giving the problem.
Please help!

///////////////////////////////////////////////////////////////////////////////////////////////////////////
<cfif division is "A">
<cfquery name="Query_AB" datasource="retail_trs">
select INumber,IcodeNumber,spm_subline,rel_month,(Total-Actuals) as Hours
From A
where INumber like '%-A' and inPace = 'Y'
order by rel_month
 </cfquery>
<cfif Query_AB.RecordCount IS 0>
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

<cfloop query="Query_AB">
<cfif form.total_hours GT hours>
<cfquery  datasource="retail_trs">
INSERT INTO C (Hours,INumber,ICodeNumber,Curdate, Emp,rel_month,spm_subline)
VALUES (#int(hours)#,'#INumber#','#IcodeNumber#','#dateformat(Now(),"DD-MMM-YYYY")#','#form.employee#','#rel_month#','#spm_subline#')
</cfquery>
</cfloop>
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0
Comment
Question by:g118481
4 Comments
 
LVL 15

Accepted Solution

by:
tim_cs earned 1000 total points
ID: 16395690
Don't know if this will solve the problem or not but try and change your cfif to one of these.

<cfif Query_AB.RecordCount IS "0">
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

or

<cfif Query_AB.RecordCount EQ 0>
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

0
 
LVL 10

Expert Comment

by:rob_lorentz
ID: 16395699
that should work.

try this...
<cfif division is "A">
<cfquery name="Query_AB" datasource="retail_trs">
select INumber,IcodeNumber,spm_subline,rel_month,(Total-Actuals) as Hours
From A
where INumber like '%-A' and inPace = 'Y'
order by rel_month
 </cfquery>
<cfdump var="#query_AB#">
<cfabort>
<cfif Query_AB.RecordCount IS 0>
<cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
</cfif>

This will tell us if the if is failing or the cfabort inside the if.
0
 
LVL 7

Expert Comment

by:JeffHowden
ID: 16396476
Maybe try a different approach:

<cfif NOT Query_AB.recordcount>
  <cfabort showerror="There is no funding available for #div1#.  Contact your manager for direction.">
<cfelse>
  ....
</cfif>
0
 
LVL 10

Expert Comment

by:Mr_Nil
ID: 16398494
If you follow Jeff's advice you should be able to do away with the cfabort all together, because there should be nothing after the end of the cfif and the code that would run if you do get a recordcount will be tucked safely away in the cfelse part of the cfif.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

581 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