【发布时间】:2012-08-11 06:10:13
【问题描述】:
使用“'”时插入失败。 示例字符串是:He's is a boy。 我尝试使用转义符号跳过“'”,但我认为这不是正确的方法。
textBox3.Text.Replace("'", " \'");
string sql= "insert into gtable (1text,1memo) values ('"+textBox3.Text+"',null)";
OleDbCommand cmd = new OleDbCommand(sql, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
我确实可以选择用“`”替换“'”,但这也会改变数据库中的文本。我希望将“'”保留为相同,并将其插入到数据库中。
【问题讨论】:
标签: c# database insert special-characters