Using variable in sql query

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

  1. #1

    Default Using variable in sql query

    Hello again,

    I'm trying to run an sql query using a string as in the following:

    <cfset string = "address1=' #evaluate("form.param#count#")# ', ">

    UPDATE philly_reads
    SET
    #string#
    WHERE masterid = '#form.masterid#'
    form.parm#count# corresponds to some inputs on the prior page of my site that
    i just named param1, param2, etc in a loop

    The problem is when i run the SQL query it replaces the single ' with " in
    string as in:

    address1=''01057 AL'',

    This obviously throws an error. Does anyone know how to make SQL take the
    single quotes as is? Thank you for any help you may give.

    -Jared


    Jared@Itron Guest

  2. Similar Questions and Discussions

    1. PARSING A QUERY OF QUERY WITH A VARIABLE VALUE
      On my first page the user selects a project. I am using the variable SelectedProject: <cfset SelectedProject =...
    2. Using a Variable to create the SQL Query
      I need to create a "dynamic" Update query. I want to store the meet of the command in a variable and then reference the variable in in query. ...
    3. Passing a variable to a query
      <cfset ctr=1> <cfloop list="#query1#" index = "i" delimiters = ","> <cfset thisColumn = "subcat_"&#ctr#> <cfquery name="insertNodes"...
    4. Help with variable query?
      I'm having an arbitrary query input by the user, then to make that query into an excel file it must be put into a table similar to below. Since I...
    5. Variable Syntax Query
      I'm building a button bank of 6 buttons whereby pressing one button releases the last button activated. Each button is it's own movie clip named...
  3. #2

    Default Re: Using variable in sql query

    The PreserveSingleQuotes function handles this quite nicely.
    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