There is probably a much more refined way of doing it, but if you think your
query will crap out for any reason
<cftry>
<cfquery>
SELECT...
</cfquery>
<cfcatch type="Any">
Do something here. Error message or a redirect maybe.
</cfcatch>
</cftry>
I'd look into the type attribute, I'd assume it would best be set to
database, but have a look anyway.
Ade
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: 22 July 2003 14:21
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] Errors cathes & throws?
I never really understood this all that well from the bygone ages.
In the following code if the user enters an incorrect username &/or
password the code will crash as the connection can't be made. Naturally
this won't do so I need to trap the error. Ideally setting a flag so that I
can include a template footer in the login page telling the user wrong
details please try again type thing.
So how do I trap the error to stop CF from crashing out ......? (Adrian
want to have a go at this one?)
Regards - Paul
<cfif isdefined("session.loggedin")>
<CFQUERY NAME="alldata"
DATASOURCE="SecureDSN"
username = '#decrypt(session.UserName,
application.key)#'
password = '#decrypt(session.password,
application.key)#'>
SELECT *
FROM Test
WHERE 0=0
</CFQUERY>
<!--- Something here? to catch the error of the wrong username &
password. --->
<!---Take user back to password login page with added note about
incorrect details --->
<!--- Maybe the catch / throw has to be around the query to be
triggered? --->
<cfoutput query="alldata">
#Name#
#Address#
</cfoutput>
<cfelse>
<cfoutput>
Before you can access this data you need to <a href
="loggedin/password.cfm" target="_top">login</a>
</cfoutput>
</cfif>
****************************************************************************
*********************
The information contained within this e-mail sent by Birmingham City Council
is confidential and is intended for the named recipient only. If you are not
the intended recipient please notify us by telephone immediately on +(44)
121 303 6666 (International) or return it to us by e-mail quoting the name
of the sender and the addressee.
****************************************************************************
*********************
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]