Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

preservesinglequotes question

Explorer ,
Aug 03, 2009 Aug 03, 2009

I have the following dynamically created sql statement:

update [tblemployees] set [FirstName]='John', [LastName]='O'neil' where employeeID = 1

I've found that it will only work if I use the preservesinglequotes in following code:

     <cfquery>
   #PreserveSingleQuotes(str)#
      </cfquery>

The problem is that it blows up when I have a user-entered single quote such as in the O'neil last name.

Does anyone have a solution for this?

530
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 03, 2009 Aug 03, 2009

Hi,

use cfqueryparam

refer - http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b20.htm    

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2009 Aug 03, 2009
LATEST

Attempting to use cfqueryparam with dynamcically created sql variables can result in excessive compication.  Another approach is to use the replace function on all your user provided text values and double up all your single quotes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources