single quotes escape during string insertion into a database

前端 未结 5 2050
不思量自难忘°
不思量自难忘° 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条回答
  •  一个人的身影
    2020-12-05 07:38

    Try this

        string sql= "insert into gtable (1text,1memo) values (@col1,NULL)";
        OleDbCommand cmd = new OleDbCommand(sql, con);
        cmd.Parameters.AddWithValue("@col1",textBox3.Text);
        con.Open();
    

提交回复
热议问题