*********************************************************** ***************************************
* Copyright Notice
* This article is Ocean all, copyright belongs to Ocean, any website
* And media reprint must contain this declaration, otherwise it will be considered as infringement, the author will
* Keep all power. This statement is an indispensable part of this article.
* Author's Name: Ocean
* Author Email:
Ocean@forever.net.cn
* Author website:
http://www.oceanstudio.net
*
http://sps.oceanstudio.net
* Author Blog: Bo Garden,
http://www.cnblogs.com/ocean
* Ocean's Blog,
http://www.oceanstudio.net/sps/blog
* This article Published: February 22, 2005
* This article source:
Http://www.cnblogs.com/ocean/archive/2005/02/22/107250.html
*********************************************************** ****************************************
Yesterday, colleagues tested a bug and found that there was a bracket in the blurring inquiry. Fuzzy queries are generally a way of like '% xxx%', and the first reaction is [is a special character, need escape. Check it out to help. And the escape is also relatively special, and the brackets are enclosed, that is, [[[], and other symbols in addition to this symbol. Think about the previous procedures, there is no escape, just replace the single quotes in it into two single quotes. And these special characters are really difficult to encounter in the query. It seems that the N multi-multi-multi-multi-program written to BUG is much more. Because I have never escaped. Corrected from now. Written a C # function, but there is no test, and it is attached to the first. Think about some bugs are often caused by insufficient experience, not that you have to avoid avoiding it. It is difficult to test how the tester does not understand. Because it is impossible to test infinity multiple strings.
Welcome everyone to visit the ocean studio (
http://sps.oceanstudio.net)
/ ** /
///
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 ();} posted on 2005-02-22 08