level 1
这是Access的BUG,SQL中无此错。这问题没有什么太好的方法,只能是用函数替换掉它们。不只输入这些,一共有26个,都会出错。没啥好办法,有位大侠提出用替换法,将26个日文字符替换,函数如下:(经我修改过了,呵呵,原来的找不到了。)Function jpEncode(strs,codeType)REM 过滤还原26个日文字符,避免Access出错Dim tmpstr,estr,dstr,elooptmpstr = strs & ""If tmpstr = "" Then Exit Functiondstr = array("&
#Jn0;","&#
Jn1;","&
#Jn2;","&#
Jn3;","&
#Jn4;","&#
Jn5;","&
#Jn6;",_"&#
Jn7;","&
#Jn8;","&#
Jn9;","&
#Jn10;","&#
Jn11;","&
#Jn12;","&#
Jn13;",_"&
#Jn14;","&#
Jn15;","&
#Jn16;","&#
Jn17;","&
#Jn18;","&#
Jn19;","&#Jn20;",_"&#Jn21;","&#Jn22;","&#Jn23;","&#Jn24;","&#Jn25;")estr = array(chr(-23116),chr(-23124),chr(-23122),chr(-23120),_chr(-23118),chr(-23114),chr(-23112),chr(-23110),_chr(-23099),chr(-23097),chr(-23095),chr(-23075),_chr(-23079),chr(-23081),chr(-23085),chr(-23087),_chr(-23052),chr(-23076),chr(-23078),chr(-23082),_chr(-23084),chr(-23088),chr(-23102),chr(-23104),_chr(-23106),chr(-23108))If codeType = 0 ThenFor eloop = 0 To 25tmpstr = Replace(tmpstr,estr(eloop),dstr(eloop))NextElseFor eloop = 0 To 25tmpstr = Replace(tmpstr,dstr(eloop),estr(eloop))NextEnd IfjpEncode = tmpstrEnd Function使用这个函数要注意以下几点:在内容入库前要经此函数转换,以一个文章系统为例,当前有两个变量,标题和内容,title content标题 内容在title和content入库前,先用jpEncode()函数转换一下,如:对title进行编码:jpEncode(title,0)同样,对content也要进行编码:对title进行解码:jpEncode(content,0)这时如果title和content中含有那26个日文字符,就会被替换成&#JNxx字样,那即然这些字符被替换了,搜索时就要再做一下功夫了,因为搜索时我们肯定是要输入正常的日文字符,不可能输入&#JNxx去搜索,所以在搜索查询时要还原。对title进行解码:jpEncode(title,1)对content进行解码:jpEncode(content,1)如:sql = "select 字段 from [表] where 字段 like '%"& jpEncode(title,1) &"%'"基本就是这样了,希望对你有所帮助。
2004年12月12日 05点12分