> 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?

PreserveSingleQuotes(), or use Replace() on the string before running the
SQL

As a single quote, it needs to be escaped before SQL Server can interpret
the SQL properly.

Philip Arnold
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


> -----Original Message-----
> From: Sean Renet [mailto:[EMAIL PROTECTED]]
> Sent: 07 July 2000 01:18
> To: [EMAIL PROTECTED]
> Subject: escaping apostrophes for database insertion.
>
>
>
>
> ------------------------------------------------------------------
> ------------
> 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