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. Database & SysAdmin
  3. Database
  4. MS SQL didn't allow to store apostrophe( ' ) in name

MS SQL didn't allow to store apostrophe( ' ) in name

Scheduled Pinned Locked Moved Database
databasehelp
4 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.
  • A Offline
    A Offline
    Azher Cybertech
    wrote on last edited by
    #1

    if v want to store name like Mohammed's then sql didn't allow to save data and give an error

    L H 2 Replies Last reply
    0
    • A Azher Cybertech

      if v want to store name like Mohammed's then sql didn't allow to save data and give an error

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Only goes wrong if you concatenate strings, which shouldn't be done in the first place. Use a 'parameterized query';

      using (cmd = new MySqlCommand("SELECT EmployeeName FROM Employees WHERE EmployeeId = @P1;"))
      {
      cmd.Parameters.AddWithValue("@P1", Parameter1);
      m.ExecuteNonQuery();
      }

      Research the AddWithValue member.

      Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

      1 Reply Last reply
      0
      • A Azher Cybertech

        if v want to store name like Mohammed's then sql didn't allow to save data and give an error

        H Offline
        H Offline
        Hitesh R
        wrote on last edited by
        #3

        to store name like Mohammed's pass Mohammed''s then it will allow to save data.

        A 1 Reply Last reply
        0
        • H Hitesh R

          to store name like Mohammed's pass Mohammed''s then it will allow to save data.

          A Offline
          A Offline
          Azher Cybertech
          wrote on last edited by
          #4

          thenks for ur reply

          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