Results 1 to 2 of 2

Thread: Apostrophe

  1. #1
    Join Date
    Dec 1969

    Default Apostrophe

    I'm sure you have answered this one, but, I have a web app that collects information from users... some in text boxes. Because of the formatting that I allow them to do (html), if they add apostrophes into the text, when they go to save (to SQL) it errors out. How can I capture and correct apostrophes so this doesn't happen?

  2. #2
    Join Date
    Dec 1969

    Default RE: Apostrophe

    If you are creating an inline SQL query and then executing it on your DB it will error out in case there is an Apostrophe in it. To avoid it you can either replace this single apostrophe with double apostrophe or u can remove it like this - <BR>Replace(strToReplace, "&#039;", "&#039;&#039;")<BR><BR>The other solution is to use CommandType.StoredProcedure and dynamically build all the parameters. In this case you dont have to do anything and the result will automatically be stored in the Db with a single apostrophe.<BR><BR>HTH<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts