Try this. In theory there is no reason why you should need a try catch
block around your query.
If no values is being sent from the from it will now default to -1 now
presuming the id starts at 1 this will return 0 if nothing is selected but
work error as form.txtSerial will always be a value.
Also you should always be using cfqueryparam to protect your self from sql
injection.
<cfparam name="form.txtSerial" default="-1" />
<cfif isDefined("FORM.Submit") >
<cfquery name="eqptid" datasource="#datamain#">
select eqptid
from eqpt
where serialno= <cfqueryparam cfsqltype="cf_sql_integer"
value="#form.txtSerial#" />
</cfquery>
</cfif>
Paul.
On Mon, Mar 9, 2009 at 5:37 PM, Servando Garcia
<[email protected]>wrote:
>
> Ok I am stuck. I am trying to catch any database errors that may happen.
> Here is what I have so far.
>
> <cfif isDefined("FORM.Submit") >
>
> <cftry>
> <cfquery name="eqptid" datasource="#datamain#">
> select eqptid from eqpt where serialno='#form.txtSerial#'
>
> </cfquery>
> <cfcatch type="Database">
> <cfoutput><strong>The serial number entered was not found in
> the database. Please click the back button on the browser and try again.
> </strong>
> <strong> <br /> If this is your second attmept please send
> all information to Sam Garcia. I will enter all information
> manually.</strong>
> </cfoutput>
> <cfabort>
> </cfcatch>
> </cftry>
>
>
> so long as the correct serial number is entered everything works great. The
> catch block is not catching any errors. When I get the catch block to work
> nothing else works.
>
> Sam
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4441
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15