我们都知道ACCESS是ASP的亲密伙伴。因为两种最简单的东西碰在一起总能迸发出火花。
然而,当我们过滤不严格的时候经常出现日文字符,这个时候搜索之后就会出现日文溢出。
此时我们通常能想到的想法是找一个exe程序,把这个问题解决掉。我原来用C#写过这样一个类似的程序。
Google里面应该能找到我以前写的那个。就不说了。
后来某一天,我发现ASP就能实现。我当时真的觉得自己太屎了。
不过ASP的这种方法很不好。容易造成系统崩溃(如果数据库大)。
所以只是写在这里。算是抛砖引玉。
'下面我解释一下下:
Function TransferJapanDc9CnInDB()
On Error Resume Next
Err.Clear
Dim objRS,i
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.CursorType = adOpenKeyset
objRS.LockType = adLockReadOnly
objRS.ActiveConnection=objConn
objRS.Source="SELECT * FROM [blog_Comment]"
objRS.Open()
If (Not objRS.bof) And (Not objRS.eof) Then
For i=1 to objRS.RecordCount
'遍历,看看有没有日文,如果有,就溢出了,随便搜索一个东西就行了。搜什么无所谓。因为是遍历ACCESS只要指针移动到日文就溢出。
objConn.Execute("SELECT * FROM [blog_Comment] WHERE comm_ID="&objRS("comm_ID")&" AND [comm_Content] LIKE '%URL%'")
If Err.Number=-2147217900 Then
'因为是on err继续 所以这里找到溢出的错误代码,这个是自己debug出来的,实际上不是从什么地方找的。
objConn.Execute("UPDATE [blog_Comment] SET [comm_Content]='"&FilterSQL(Japan2Html(objRS("comm_Content")))&"',[comm_Author]='"&FilterSQL(Japan2Dc9CnHtml(objRS("comm_Author")))&"' WHERE comm_ID="&objRS("comm_ID")&" ")
'这个就是把日文替换一下,思路是不是很巧妙。恩。不过数据库庞大的化,反复溢出就会很出问题的。内存宝宝会哭的。
Err.Clear
End If
objRS.MoveNext
Next
End If
objRS.Close
Set objRS=Nothing
'www.dc9.cn http://www.devdao.com/ 07/11/28
End Function
Function Japan2Dc9CnHtml(source)
source=Replace(source,"ガ","ガ")
source=Replace(source,"ギ","ギ")
source=Replace(source,"ア","ア")
source=Replace(source,"ゲ","ゲ")
source=Replace(source,"ゴ","ゴ")
source=Replace(source,"ザ","ザ")
source=Replace(source,"ジ","ジ")
source=Replace(source,"ズ","ズ")
source=Replace(source,"ゼ","ゼ")
source=Replace(source,"ゾ","ゾ")
source=Replace(source,"ダ","ダ")
source=Replace(source,"ヂ","ヂ")
source=Replace(source,"ヅ","ヅ")
source=Replace(source,"デ","デ")
source=Replace(source,"ド","ド")
source=Replace(source,"バ","バ")
source=Replace(source,"パ","パ")
source=Replace(source,"ビ","ビ")
source=Replace(source,"ピ","ピ")
source=Replace(source,"ブ","ブ")
source=Replace(source,"ブ","ブ")
source=Replace(source,"プ","プ")
source=Replace(source,"ベ","ベ")
source=Replace(source,"ペ","ペ")
source=Replace(source,"ボ","ボ")
source=Replace(source,"ポ","ポ")
source=Replace(source,"ヴ","ヴ")
Japan2Html=source
End Function
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |