日期:2014-05-18  浏览次数:20427 次

转义符 求救。。。。。。。。。。。
获取的值是   textbox.text=src= "//2007991056087577801.jpg "

可是用数据库替换的时候,update   aa   set   img=replace(aa, ' "+textbox.text " ', ' ')

' "+textbox.text " '的值自动改为 'src=\ "//2007991056087577801.jpg\ " '

有什么办法让他不替换

------解决方案--------------------
上面这些是你自己手写的吧,楼主还是贴你程序中的代码吧
textbox.text=src= "//2007991056087577801.jpg "
update aa set img=replace(aa, ' "+textbox.text " ', ' ')
这两个明显不对

你在哪里看到如下内容的
'src=\ "//2007991056087577801.jpg\ " '
如果是设断点查看的,那是没问题的,\ "在字符串中对 "转义,在实际输出时,只是一个 ",并不会有\的
------解决方案--------------------
用Sql参数吧,就不用转换来转换去的了

string sql = "update aa set img=@img ";
OleDbParameter prram = new OleDbParameter( "@img ", OleDbType.VarChar, 40);
param.Value = "你的值 ";

//然后在Command对象中,添加Sql参数
command.Parameters.Add(param);
command.ExecuteNonQuery();