You need to make sure form.field contains a valid column and kill the query
if it doesn't. Your use of evaluate is not the worst thing about this sample
query (ha).


Try this......


 <cfset colList = "col1,col2,col3"/>

<cfquery name="getPhysicianRecords" datasource="#DSN#">
        SELECT *
        FROM Contacts
        WHERE Contacts.ContactType = <cfqueryparam cfsqltype="CF_SQL_CHAR"
value="Physician"/>
        
        <cfif listfindnocase(colList,form.field)>
                AND     Contacts.#form.field = <cfqueryparam
cfsqltype="CF_SQL_CHAR" value="#form[form.field]#"/>
        <cfelse>
                <!---  ensure the query will fail --->
                AND 1 = 2
        </cfif>
        
        ORDER BY Contacts.LastName
 
</cfquery> 


Mark A. Kruger, CFG, MCSE
(402) 408-3733 ext 105
www.cfwebtools.com
www.coldfusionmuse.com
www.necfug.com

-----Original Message-----
From: David Moore, Jr. [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 10, 2008 9:04 AM
To: CF-Talk
Subject: Re: How NOT to Evaluate (moved from cfset so not to confuse topic)

Ray wrote:
 
> As someone who used to always pounce on folks for using evaluate, I>
believe I remember reading recently a blog entry from an Adobian that>
points out that evaluate is not nearly as slow as it used to be.> > Now when
I recommend against Evaluate I do so on readability terms> rather than
performance. For almost every use of evaluate I see in the> field, the code
can be rewritten in a cleaner, easier to understand> manner.
How then would you approach the following without Evaluate, because it was
the only way I could get it to work: (oh, let the fun begin, the shame. I
probably committed at least 7 deadly sins alone. And yes, I am using Access.
Moan. Laughter.) In my ever growing need to expand my knowledge base (and
look less like an idiot to this list) HELP? It's a query that accepts
information from a Search field to run a query.
 
<cfquery name="getPhysicianRecords" datasource="#DSN#">SELECT *FROM
ContactsWHERE Contacts.ContactType = 'Physician' 
 AND Contacts.#FORM.Field# = '#Evaluate("FORM.#FORM.Field#")#'ORDER BY
Contacts.LastName~David
_________________________________________________________________
See how Windows connects the people, information, and fun that are part of
your life.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312307
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to