Escaping characters...please help!!!!
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sarada_Lakhamraju
Posted On:   Friday, October 4, 2002 10:55 AM

Hello All, I have a name O'brain which has to be used in the SQL update query, the SQL string goes this way SQL = "Update Anything set Name = 'O\'Brain' where ID = 11"; here I have used slash to escape the single quote, but when I use this query in statement.executeUpdate(SQL), I get the following error during execution. Error com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near 'Brain'. Is there any solution to this problem other than using prepared statements?? Can anyone clearly explain me about the setObject() method, if it can be used to solve this problem??? I have read about URLEncoder and URLDecoder, but I guess for data   More>>

Hello All,

I have a name O'brain which has to be used in the SQL update query, the SQL string goes this way
SQL = "Update Anything set Name = 'O\'Brain' where ID = 11";
here I have used slash to escape the single quote, but when I use this query in statement.executeUpdate(SQL), I get the following error during execution.

Error com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near 'Brain'.

Is there any solution to this problem other than using prepared statements??

Can anyone clearly explain me about the setObject() method, if it can be used to solve this problem???

I have read about URLEncoder and URLDecoder, but I guess for database updations if I encode the name then I will have to insert the encoded name, which is not appropriate.


Thanks & Regards,

Sarada.

   <<Less

Re: Escaping characters...please help!!!!

Posted By:   Stephen_Ostermiller  
Posted On:   Sunday, October 6, 2002 05:40 PM

Re: Escaping characters...please help!!!!

Posted By:   amit_anand  
Posted On:   Friday, October 4, 2002 11:24 AM

You might try to enclose O'Brien in Double Quotes. Ofcourse you have to properly escape the double quotes in your string
About | Sitemap | Contact