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. General Programming
  3. Visual Basic
  4. Insert Quote and Double Quote in DB

Insert Quote and Double Quote in DB

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
4 Posts 4 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.
  • C Offline
    C Offline
    charchabil03
    wrote on last edited by
    #1

    Hey Guys I have problem inserting single and double quotes in DB How can i insert single Quote and Double Quotes in DB Can You provide me a simple code for that

    Regards Ramy

    R G D 3 Replies Last reply
    0
    • C charchabil03

      Hey Guys I have problem inserting single and double quotes in DB How can i insert single Quote and Double Quotes in DB Can You provide me a simple code for that

      Regards Ramy

      R Offline
      R Offline
      Rupesh Kumar Swami
      wrote on last edited by
      #2

      hi, use this one q = "select * from main where lotnumber like " & """" & ComboBoxlotnumber.Text.Trim & "%" & """" here ComboBoxlotnumber.Text.Trim may contain single & double quotes hope this helps

      Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India)

      1 Reply Last reply
      0
      • C charchabil03

        Hey Guys I have problem inserting single and double quotes in DB How can i insert single Quote and Double Quotes in DB Can You provide me a simple code for that

        Regards Ramy

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Apostrophes inside a string in SQL has to be encoded, and depending on what database you are using, backslashes also. There is nothing special about quotes in a string, so if you have problem with them, there is something else that you are doing wrong. For MySQL: Replace "\" with "\\" and replace "'" with "\'" (in that order). For MSSQL, Access: Replace "'" with "''".

        --- single minded; short sighted; long gone;

        1 Reply Last reply
        0
        • C charchabil03

          Hey Guys I have problem inserting single and double quotes in DB How can i insert single Quote and Double Quotes in DB Can You provide me a simple code for that

          Regards Ramy

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Use parameterized queries to store the information in the database and you don't have to worry about escaping the quote marks. SQL Injection Attacks and Some Tips on How to Prevent Them[^]

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          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