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. ASP.NET
  4. apostrophe in sql

apostrophe in sql

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelp
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.
  • J Offline
    J Offline
    jithbiz0033
    wrote on last edited by
    #1

    Hi Guys, I have a problem while inserting data containing ' into my MS SQL database through web form. I have formatted the string using stringvariablename.Replace("'","''").This is working in the local system.But not in the website.(ASP .NET 2.0,C#).And i want to know if there are anyother special characters which could raise exception while inserting. If anyone has solution for this kindly reply. Thanks Jith

    C C 2 Replies Last reply
    0
    • J jithbiz0033

      Hi Guys, I have a problem while inserting data containing ' into my MS SQL database through web form. I have formatted the string using stringvariablename.Replace("'","''").This is working in the local system.But not in the website.(ASP .NET 2.0,C#).And i want to know if there are anyother special characters which could raise exception while inserting. If anyone has solution for this kindly reply. Thanks Jith

      C Offline
      C Offline
      coolestCoder
      wrote on last edited by
      #2

      If you are using this in a web application, use the HtmlEncode and HtmlDecode methods. HtmlEncode when inserting or updating data and HtmlDecode when retrieving data.


      "A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder


      coolestCoder

      1 Reply Last reply
      0
      • J jithbiz0033

        Hi Guys, I have a problem while inserting data containing ' into my MS SQL database through web form. I have formatted the string using stringvariablename.Replace("'","''").This is working in the local system.But not in the website.(ASP .NET 2.0,C#).And i want to know if there are anyother special characters which could raise exception while inserting. If anyone has solution for this kindly reply. Thanks Jith

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        jithbiz0033 wrote:

        I have formatted the string using stringvariablename.Replace("'","''").

        You might want to read SQL Injection Attacks and tips on how to prevent them[^] and then start using parameterised queries.


        Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

        J 1 Reply Last reply
        0
        • C Colin Angus Mackay

          jithbiz0033 wrote:

          I have formatted the string using stringvariablename.Replace("'","''").

          You might want to read SQL Injection Attacks and tips on how to prevent them[^] and then start using parameterised queries.


          Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

          J Offline
          J Offline
          jithbiz0033
          wrote on last edited by
          #4

          Hi Colin Nice article.It has cleared my future doubts in advance. Thanks:cool: Jith

          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