SQL Server Performance

problem with sending (') as string

Discussion in 'Getting Started' started by Pankaj18, Oct 22, 2009.

  1. Pankaj18 New Member


    I have problem, i have designed a web page in asp.net 3.5. I have a TextBox and a button, the User is expected to write some comment in the TextBox. The TextBox can also have a comment pattern including a (') on the click of button the data in the TextBox will be inserted into SQL.

    Now the problem is : as you know that if u insert something in Varchar it has to be enclosed in ('), but in above case due to (') in the string itself there will be an error

    So, is there a way to insert the data in SQL.

  2. Adriaan New Member

    Your description is not quite clear, but it seems like your code is concatenating a written command with the value from the TextBox, and then the whole command will be executed by SQL Server, correct?
    Most programming languages have standard function to replace one string with another. Use this on the value from the TextBox, to replace each single quote character - Chr(39) - with two single quote characters - Chr(39) & Chr(39)
  3. Pankaj18 New Member

Share This Page