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?

Answers


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>

Need Your Help

Can I control the number of digits displayed in debugger windows for float and double variables?

c++ debugging visual-studio-2012 natvis

In Visual Studio 2012, I'm looking for a way to customize the default display of floating point types in the Autos, Locals, and Watch windows. I'm familiar with the Native Visualizer (Natvis) utili...

How to plot 1d C array as surface in python

python c plot surface

Say I have a one-dimensional array of size NxN in C which I think of as a two-dimensional array, i.e. every N entries, a new row begins.