Sean,

Try using the PreserveSingleQuotes() function.

<cfquery name="myquery" ...>
insert into mytable(MESSAGE_MEM)
        values('#trim(PreserveSingleQuotes(Message))#')

</cfquery>

-----Original Message-----
From: Sean Renet [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 06, 2000 6:18 PM
To: [EMAIL PROTECTED]
Subject: escaping apostrophes for database insertion.


Lets say I have a variable called message.

Message looks like:

<cfset message = "I can't make it today">

I want to input it into a database:

<cfquery name="myquery" ...>
insert into mytable(MESSAGE_MEM)
        values('#trim(Message)#')

</cfquery>

Because CF thinks the apostrophe in "can't" is closing the inserting
variable I get this error.
ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][ODBC SQL Server Driver][SQL Server]Line 10: Incorrect syntax
near 't'.



What is the trick for escaping the apostrophe?


----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to