All the 'PreserveSingleQuotes(SQL)' function will do it pass your string to the 
database server unadulterated. If you don’t use it then CF will automatically 
double up on all the single quotes in your string. For example

<CFSET name = "O'Brien">
<CFQUERY>
        INSERT 
      INTO names (thename)
        VALUES ('#name#')
</CFQUERY>

This gets sent to the DB server looking like this:
INSERT
INTO names (thename)
VALUES ('O''Brien')

Automagically! Its one of the things CF does for us behind the scenes.

If you want to write the string directly you would need to double the qutoes 
yourself:

<CFQUERY>
        INSERT 
      INTO names (thename)
        VALUES ('O''Brien')
</CFQUERY>

Or the SQL Server will not parse your query.

Where you would use PreserveSingleQuotes would be when you are building the 
entire query text yourself outside the CFQUERY tag, e.g.:

<CFSET myQuery = "INSERT INTO names (thename) VALUES ('O''Brien')">
<CFQUERY>
        #PreserveSingleQuotes(myQuery)#
</CFQUERY>

If you didn’t do that, then CF would still double all your quotes, creating a 
badly formatted string of SQL and possibly destroying the universe.

Make sense?


---
You are currently subscribed to cfaussie as: archive@mail-archive.com
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to