sql server数据库中插入<img src='F:\virus alarm\bin\Debug\image\2006_09_18_155008xin.rar'>
出现错误,把''去掉就没问题了,现在不能去掉'',该怎么插入数据呀?急,各位大霞帮帮忙吧

解决方案 »

  1.   

    @"<img src='F:\virus alarm\bin\Debug\image\2006_09_18_155008xin.rar'>"
      

  2.   

    我猜你是的拼SQL语句的问题,也是注入式SQL攻击的根源,解决方法如下:
    1:用replace覆盖特殊字符,比如单引号 换成 2个单引号。
    2:使用参数化。
    推荐你使用第2种方法。
      

  3.   

    上上面的第1种方法:
    string s = "<img src='F:\virus alarm\bin\Debug\image\2006_09_18_155008xin.rar'>";
    s = s.Replace("'","''");
    将单引号换成两个连续的单引号