SQLSERVER filter insert special characters INSERT INTO

/// <summary>
/// special character filtering
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
private static string String2Json(string s)
{
return s.Replace("'", "'+char(39)+'").Replace("&", "'+char(38)+'");
}

  

Wherein the char (39) on behalf of single quotation marks' char (38) & behalf of some other character it needs to be filtered on the back like a mosaic, is the result of the query below

       

select char(39)
select char(38)

 

Guess you like

Origin www.cnblogs.com/dushaojun/p/11002181.html