single quotes escape during string insertion into a database

前端 未结 5 2038
不思量自难忘°
不思量自难忘° 2020-12-05 07:11

Insertion fails when \"\'\" is used. example string is: He\'s is a boy. I\'ve attempted to skip the \"\'\" using an escape symbol , but I believe this is not the right way.<

5条回答
  •  -上瘾入骨i
    2020-12-05 07:45

    try

    string sql= "insert into gtable (1text, 1memo) " + 
                "values ('" + textBox3.Text.Replace("'", "''") + "', null)";
    

提交回复
热议问题