How to ignore ' char in sql query, c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lightwalker19
    New Member
    • Apr 2012
    • 22

    How to ignore ' char in sql query, c#

    Hello how can i ignore a ' char in a sql query?
    i want to put this into a table,"i can't work today."
    but it gives this error "Incorrect syntax near 't'.
    Unclosed quotation mark after the character string ')'."
    please help :(


    Code:
     
     
    AppSettingsReader asr = new AppSettingsReader();
    string conn = asr.GetValue("ConnectionString", typeof(System.String)).ToString();
    SqlConnection sc = new SqlConnection(conn);
    sc.Open();
    string query = "INSERT INTO Lang(lang)VALUES('" + "i can't work today." + "')";
    
    SqlCommand command = new SqlCommand(query, sc);
    command.ExecuteNonQuery();
    sc.Close();
  • lightwalker19
    New Member
    • Apr 2012
    • 22

    #2
    Found the solution.... I was coding wrong :P http://www.csharp-station.com/Tutori.../Lesson06.aspx

    Comment

    Working...