///
<summary>
/// 对字符串进行sql格式化,并且符合like查询的格式。
/// </summary>
/// <param name="str"> 要转换的字符串 </param>
/// <returns> 格式化后的字符串 </returns>
public static string ToLikeSql( string sqlstr)
{
if (sqlstr == null ) return "" ;
StringBuilder str = new StringBuilder(sqlstr);
str.Replace( " ' " , " '' " );
str.Replace( " [ " , " [[] " );
str.Replace( " % " , " [%] " );
str.Replace( " _ " , " [_] " );
return str.ToString();
}
/// 对字符串进行sql格式化,并且符合like查询的格式。
/// </summary>
/// <param name="str"> 要转换的字符串 </param>
/// <returns> 格式化后的字符串 </returns>
public static string ToLikeSql( string sqlstr)
{
if (sqlstr == null ) return "" ;
StringBuilder str = new StringBuilder(sqlstr);
str.Replace( " ' " , " '' " );
str.Replace( " [ " , " [[] " );
str.Replace( " % " , " [%] " );
str.Replace( " _ " , " [_] " );
return str.ToString();
}