Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CF Try Catch  Cold Fusion

Posted on 2007-11-15
2
Medium Priority
?
4,355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

618 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