CF double quoting my single quotes in query string

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default CF double quoting my single quotes in query string

    I'm building my query string on the fly. So I have something like this:
    <cfset szQuery = "SELECT id FROM tblFoo WHERE id=' " &
    #Trim(evaluate(szVarName))# & " ' ">
    (I've added a few extra blank spaces to improve readability).
    When I do a <cfoutput> of my string, it looks correct. I get:

    SELECT id FROM tblFOO WHERE id='5'

    However, I get an error running it, and apparently SQL server sees this:

    SELECT id FROM tblFOO WHERE id=''5'' (CF adds another single quote - so
    it's really two single quotes, not the " character)

    Why is CF double quoting my single quote? It's causing me to fail. If I
    don't single quote at all, CF doesn't put anything there so my statement simply
    becomes: id=5.


    lerxst3 Guest

  2. Similar Questions and Discussions

    1. Variable double quoting in SQL query when should besingle quote
      Hi Anna Try using the PreseveSingleQuotes function. ie. WHERE Town in ('#PreseveSingleQuotes(TownList)#') HTH Zoe
    2. Single and Double quotes in SQL
      On Sat, 20 Sep 2003 21:34:58 +0000, Pablo Fischer wrote: $html_text =~ s/'/''/g; $html_text =~ s/"/""/g; Use the help of regular expressions to...
    3. Single Quotes vs Double Quotes
      With all that's been said in mind ('$var' unparsed "$var" parsed). The rule of thumb I follow is, if it needs to be parsed (has a $variable or \n...
    4. [PHP] Single Quotes vs Double Quotes
      Hi, Tuesday, September 9, 2003, 2:03:34 PM, you wrote: mb> Hi everyone, mb> Could somebody please explain to me the difference mb> between...
    5. [OT] REXML and double, rather than single quotes
      Ian Macdonald <ian@caliban.org> wrote in message news:<20030624010502.GH7020@caliban.org>... If I may digress, I'd like to re-make on observation...
  3. #2

    Default Re: CF double quoting my single quotes in query string

    The preservesinglequotes function will help you out. Details are in the cfml
    reference manual. If you don't have one, the internet does.

    For my curiousity, why is your id field text instead of numeric?

    Dan Bracuk Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139