CF Try Catch Cold Fusion

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
<cfloop query="GetBanners">
<cfif DateFormat(GetBanners.StartDate,'short') EQ DateFormat(Now(),'short') >
<cfquery datasource="FCData" name="UpdateBanners">
Update tTechCellBannerList
Weight = 1
WHERE ID = #Get Banners.ID#
<cfcatch type = "Any">
 <cfmail to=""
 subject="Techcell Banner Update Status Error"

Open in new window

Who is Participating?
_agx_Connect With a Mentor Commented:
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">

Open in new window

Albee_JAuthor Commented:
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....
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.