This is getting to be quite an interesting challenge.  All the examples I've 
seen logically make sense but none of them have worked so far.  I will say I'm 
learning quite a bit from everyone's knowledge/wisdom.  I will try and list 
here all the different methods I've tried out and have failed.  First, the 
method I've used (and still using):

<cfif isDefined("form.myVal")><cfqueryparam cfsqltype="cf_sql_varchar" 
value="#form.myVal#" maxlength="50"><cfelse><cfqueryparam null="yes"></cfif>

Examples that have not worked (unless I cfparam the variable):

<cfqueryparam value="#form.myVar#" null='#not IsDefined("form.myVar")#'>
<cfqueryparam value="#form.myVar#" null="#not IsDefined('form.myVar')#">
<cfqueryparam value="#form.myVar#" null="#not IsDefined('form.myVar')#">
<cfqueryparam value="#form.myVar#" null="#not Len(Trim(form.myVar))#" /> 
<cfqueryparam type="cf_sql_varchar" value="#form.myVar#" isNull="#NOT 
isDefined(form.myVar)#" /> (actually got a different error on this one and 
couldn't figure it out for some reason  Attribute validation error for tag 
CFQUERYPARAM. Usually it's because I'm passing the wrong cf_sql_type, but I 
took that out and it still gave me the error)
<cfqueryparam type="cf_sql_varchar" value="#form.myVar#" 
isNull="#yesNoFormat(NOT isDefined(form.myVar)#" />
<cfqueryparam type="cf_sql_varchar" value="#form.myVar#" 
isNull="#YesNoFormat(NOT Len(Trim(form.myVar)))#" />
<cfqueryparam type="cf_sql_varchar" value="#form.myVar#" 
isNull="#yesNoFormat(not structKeyExists(form, 'myVar'))#" />
<cfqueryparam type="cf_sql_varchar" value="#form.myVar#" 
isNull="#yesNoFormat(not len(trim(form.myVar)))#" />

I went ahead and re-tried all these examples above.  Most (if not all) these 
examples should work logically.  Also, for the record I'm currently using:
Coldfusion 9
SQL Server 2005

Thank again for everybody's help and wisdom!

Best Regards
Matt..

>>  what Dominic meant is that value="#somevalue#" in cfqueryparam tag
>> cause the problem when somevalue var does not exist, not the
>> isDefined("somevalue") part.
>
>Oh, well, yes - that would cause a problem! I didn't even think about that 
>part.
>
>Dave Watts, CTO, Fig Leaf Software
>http://www.figleaf.com/
>http://training.figleaf.com/
>
>Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
>GSA Schedule, and provides the highest caliber vendor-authorized
>instruction at our training centers, online, or onsite

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333293
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to