Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Replace " ' " symbol in my code

Replace " ' " symbol in my code

Scheduled Pinned Locked Moved Web Development
helpdatabasesysadminquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BravoTwoZero
    wrote on last edited by
    #1

    Hello All, I have a validation, replacing quotation mark in my dll as soon as surname or first name has been passed from my form. The code is : CStr(Replace(Trim(surname), " ' ", "$0")) The problem is when I type a surname = "O'Brian" the data does not go to the database and has internal server error. Can anybody suggest any other way I can liminate this problem? Many Thanks :rolleyes: Bravo Two Zero A pen is mighter then a sword.

    P B 2 Replies Last reply
    0
    • B BravoTwoZero

      Hello All, I have a validation, replacing quotation mark in my dll as soon as surname or first name has been passed from my form. The code is : CStr(Replace(Trim(surname), " ' ", "$0")) The problem is when I type a surname = "O'Brian" the data does not go to the database and has internal server error. Can anybody suggest any other way I can liminate this problem? Many Thanks :rolleyes: Bravo Two Zero A pen is mighter then a sword.

      P Offline
      P Offline
      Philip Patrick
      wrote on last edited by
      #2

      To place a single quotation mark into database, just repeat it, e.g. to use "O'Brian" in your SQL statement, you should replace it with "O''Brian". You do not need to do that though if you are using ADO's Recordest("field") = "O'Brian" Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer

      1 Reply Last reply
      0
      • B BravoTwoZero

        Hello All, I have a validation, replacing quotation mark in my dll as soon as surname or first name has been passed from my form. The code is : CStr(Replace(Trim(surname), " ' ", "$0")) The problem is when I type a surname = "O'Brian" the data does not go to the database and has internal server error. Can anybody suggest any other way I can liminate this problem? Many Thanks :rolleyes: Bravo Two Zero A pen is mighter then a sword.

        B Offline
        B Offline
        Black Cat
        wrote on last edited by
        #3

        It looks like you probably used the variable surname as part of a SQL statement. With SQL, the value has to be quoted by ' such as: select * from myTable where name = 'John Smith' If the name value itself contains a ', the SQL statement is invalid: select * from myTable where name = 'John's Smith' What you need to do is replace ' with two consecutive ', like the following: select * from myTable where name = 'John''s Smith' CStr(Replace(Trim(surname), "'", "''")) Good luck.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups