Using # and " in ColdFusion query gives error
I am trying to insert the following string in my DB using CF query: Aman#30 is "OK"
But I get the error "Invalid construct: Either argument or name is missing."
On further investigation I found that this happens only if I use # or " in the string.
Any suggestions on how to resolve this issue?
You'll most likely need to escape the pound-sign and the quotes. For example:
<CFSET yourstring = "Aman##30 is ""OK""" /> <CFQUERY result="qRes" datasource="#yourDSN#"> INSERT INTO `yourtable` (`yourstringfield`) VALUES (<CFQUERYPARAM value="#yourstring#" cfsqltype="cf_sql_varchar" />) </CFQUERY>