By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,378 Members | 1,407 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,378 IT Pros & Developers. It's quick & easy.

Apostrophe

OuTCasT
100+
P: 374
Can anyone tell me why an word with an apostrophe cannot be saved to the db?

i get this error

Incorrect syntax near 's'.
Unclosed quotation mark after the character string ')'.

got some textboxes on a web form. and i encountered this error when i tried to save for example, sweet's ??

is there a solution for it ?
Apr 16 '08 #1
Share this Question
Share on Google+
4 Replies


ck9663
Expert 2.5K+
P: 2,878
Can anyone tell me why an word with an apostrophe cannot be saved to the db?

i get this error

Incorrect syntax near 's'.
Unclosed quotation mark after the character string ')'.

got some textboxes on a web form. and i encountered this error when i tried to save for example, sweet's ??

is there a solution for it ?

Because a single quote is signifies string constant. If you want it stored that way, you might want to handle that. Depending on your requirement, you can either replace it with '' (two single quotes) or a double quote ("). If you're doing the double quote, you have to handle it back to a (one) single quote when you retrieve it back for your front-end.

Happy Coding.

-- CK
Apr 16 '08 #2

OuTCasT
100+
P: 374
Because a single quote is signifies string constant. If you want it stored that way, you might want to handle that. Depending on your requirement, you can either replace it with '' (two single quotes) or a double quote ("). If you're doing the double quote, you have to handle it back to a (one) single quote when you retrieve it back for your front-end.

Happy Coding.

-- CK
I did read about that -- CK
replace ("" ' "") or something like that.

things can never just be straight forward now can they.
Apr 17 '08 #3

amitpatel66
Expert 100+
P: 2,367
I did read about that -- CK
replace ("" ' "") or something like that.

things can never just be straight forward now can they.
Why are you not able to replace a single quote with a two single quotes

Check this:

Expand|Select|Wrap|Line Numbers
  1.  
  2.   1* SELECT REPLACE('Your''s','''','''')
  3. SQL> /
  4.  
  5. REPLAC
  6. ------
  7. Your's
  8.  
  9. SQL> ed
  10. Wrote file afiedt.buf
  11.  
  12.   1* SELECT REPLACE('Your''s','''','''''')
  13. SQL> /
  14.  
  15. REPLACE
  16. -------
  17. Your''s
  18.  
  19. SQL> 
  20.  
  21.  
Apr 17 '08 #4

ck9663
Expert 2.5K+
P: 2,878
I did read about that -- CK
replace ("" ' "") or something like that.

things can never just be straight forward now can they.
Yep.

The more they things get simple, the more they get complicated ;)

-- CK
Apr 17 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.