Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with ODBC Error Trapping

Status
Not open for further replies.

bmacman

IS-IT--Management
Feb 19, 2001
51
US
Hello, I am trying to figure out how to trap an ODBC error that occurs when I pass a login id and password from a login screen to be the same user id and password to connect to a database to execute a query. The problem that I am encountering is that when a wrong password is entered, we get a generic ODBC 28000 error and we can not figure out how to trap this and customize an error response. I have included the code of the page that is accessed right after the login page:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html>
<head>
<title>Developers Corner Site Access</title>

<cfquery name=&quot;Devseccheck&quot; datasource=&quot;teradata32_edw&quot; username=&quot;#form.user_id#&quot; password=&quot;#form.password&quot;>
Select user_id, access(named sec_level)
from C_R.TCCRB045_BO_CNTC_SEC
where user_id = '#form.User_ID#'
</cfquery>
</head>

<body>

<cfif #Devseccheck.recordcount# is 0>
<br><br><br><br>
<CENTER><P><font face=&quot;Tahoma&quot; size=&quot;4&quot;>
The User ID you entered could not be located in this system.<br>
Please check the User ID you entered, or, <br>
if you would like to request access, please send a request to the
<a href=&quot;mailto:hlp@sbc.com&quot;>Contact/ECM Support Desk</a> </font></P></center>

<cfelseif #passcheck.recordcount# greater than 0>
<CFOUTPUT>
<cfif #Devseccheck.sec_level# contains &quot;ITADM&quot;>
<CFLOCATION URL=&quot;devitadm.cfm&quot;>
<cfelseif #Devseccheck.sec_level# contains &quot;ITCNTC&quot;>
<CFLOCATION URL=&quot;devitcntc.cfm&quot;>
<cfelseif #Devseccheck.sec_level# contains &quot;ITECM&quot;>
<CFLOCATION URL=&quot;devitecm.cfm&quot;>
<cfelseif #Devseccheck.sec_level# contains &quot;ITHLP&quot;>
<CFLOCATION URL=&quot;devithlp.cfm&quot;>
<cfelseif #Devseccheck.sec_level# contains &quot;ECMMGR&quot;>
<CFLOCATION URL=&quot;devecmmgr.cfm&quot;>
<cfelseif #Devseccheck.sec_level# contains &quot;ECMUSR&quot;>
<CFLOCATION URL=&quot;devecmusr.cfm&quot;>
<cfelse>
<br><br><br><br>
<CENTER><P><font face=&quot;Tahoma&quot; size=&quot;4&quot;>
You are not authorized to access the Developers Corner.
If you would like to request access, please send a request
to the <a href=&quot;mailto:hlp@sbc.com&quot;>Contact/ECM Support Desk</a>
</font></P></center>
</cfif>
</cfoutput>
</cfif>
</cfif>

</body>
</html>


Thank you for all your help
 
You may be interested in CFCATCH/CFTRY

There are a couple examples you can look at:



Basically, you could do:

<cftry>

<cfquery name=&quot;Devseccheck&quot; datasource=&quot;teradata32_edw&quot; username=&quot;#form.user_id#&quot; password=&quot;#form.password&quot;>
Select user_id, access(named sec_level)
from C_R.TCCRB045_BO_CNTC_SEC
where user_id = '#form.User_ID#'
</cfquery>

<cfcatch type=&quot;Database&quot;>
..set an error messge OR
..return them to the form...
</cfcatch>
</cftry>
 
Hey Bmacman,

Try this:

<cftry>
<cfquery name=&quot;Devseccheck&quot; datasource=&quot;teradata32_edw&quot;
username=&quot;#form.user_id#&quot; password=&quot;#form.password&quot;>
Select user_id, access(named sec_level)
from C_R.TCCRB045_BO_CNTC_SEC
where user_id = '#form.User_ID#'
</cfquery>
<cfcatch>
<cfoutput>#cfcatch.message# #cfcatch.detail#</cfoutput>
</cfcatch>
</cftry>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top