Solved

CF Try Catch  Cold Fusion

Posted on 2007-11-15
2
4,331 Views
Last Modified: 2013-12-16
We have this page that we are running nightly.  I can't get the email to fire off if there is an error..



<cfquery name ="GetBanners" datasource="FCdata">

SELECT     ID, StartDate, Weight

FROM         tTechCellBannerList

ORDER BY StartDate DESC

</cfquery>
 

<cftry>

<cfloop query="GetBanners">

<cfif DateFormat(GetBanners.StartDate,'short') EQ DateFormat(Now(),'short') >

<cfquery datasource="FCData" name="UpdateBanners">

Update tTechCellBannerList

SET 

Weight = 1

WHERE ID = #Get Banners.ID#

</cfquery>

</cfif>

</cfloop>

<cfcatch type = "Any">

 <cfmail to="webhelp@fmanet.org"

 from="Info@thefabricator.com"

 subject="Techcell Banner Update Status Error"

 type="html">

 #cfcatch.detail#

 </cfmail>

</cfcatch>

  

</cftry>

Open in new window

0
Comment
Question by:Albee_J
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 20290709
There's nothing wrong with the code.  It generates and error (and email) because of the space in the query name: #Get Banners.ID#.  Have you properly configured your mail server in the CF Administrator?  

But both queries should be inside the cftry/cfcatch  and you should be able to do the update in one query.  The exact syntax depends on your database and column type.






   <cfset today = createDate(year(now()), month(now()), day(now()))>

   <cfquery datasource="FCData" name="UpdateBanners">

      UPDATE   tTechCellBannerList

      SET    Weight = 1

      WHERE    StartDate >= <cfqueryparam value="#today#" cfsqltype="cf_sql_date">

      AND      StartDate < <cfqueryparam value="#dateAdd('d', 1, today)#" cfsqltype="cf_sql_date">

   </cfquery>

Open in new window

0
 

Author Comment

by:Albee_J
ID: 20290840
Great I will give that a shot and give you the update.

I put a space in   #Get Banners.ID# on purpose because I was trying to generate an error to trigger the email to be sent....
0

Featured Post

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do you create a simple buy now button for a website? 7 63
Online video resource for customers 3 117
Blue Coat API portal URL 2 141
segregating a list into two lists 4 66
The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

920 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

14 Experts available now in Live!

Get 1:1 Help Now