The whole process is divided into two parts: the generation of phonetic code fields, the fuzzy query by phonetic code.
Implementation of batch generation of phonetic code fields:
protected void Button1_click1 (object sender, EventArgs e) {string strSQL;
strSQL = "Select MC from TEST001"; IDataReader dr = DAC.
Datareaderquery (strSQL); while (Dr. Read ()) {string mc=dr["MC"].
ToString ();
String Pym = Strtopinyin.getchinesespell (MC); if (Pym. Length > 6) {pym = Pym.
Substring (0, 6);//I only went to 6 places, we can see their hobbies and set!
} string updatesql = "Update TEST001 Set Pym = ' + Pym +" ' where mc= ' "+ MC +" ";
Dac.update (Updatesql); } Dr.
Close (); Response.Write ("Successful operation! ');" <script>alert
</script> "); Getchinesespell method for Strtopinyin class (kanji Pinyin): public static string Getchinesespell (String strText) {if (StrText = null ||
Strtext.length = = 0) return strText;
System.Text.StringBuilder mystr = new System.Text.StringBuilder (); foreach (char Vchar in strText) {//If not kanji, direct output if ((int) Vchar < 19968 | | (int) Vchar > 40869) {mystr.append (char.
ToUpper (Vchar)); else if (int) Vchar >= 19968;& (int) Vchar <= 40869) {//If the character Unicode encoding is in the encoding range, check the Chinese character list for conversion output foreach (String strlist in Strchinesecharlist)
{if (Strlist.indexof (Vchar) > 0) {mystr.append (strlist[0]);
Break
}}} return Mystr.tostring (); }
Fuzzy query by phonetic code:
This simple, with select query, where conditions with like can, I believe we will be able to operate.
believe that in the realization of the user input Pinyin code for the data of the fuzzy query function, we can use today to learn the asp.net implementation by Pinyin code fuzzy query.