ASP代码实现自动清除替换ACCESS(MDB)数据库的日文字符的
(编辑:jimmy 日期: 2024/11/17 浏览:3 次 )
此时我们通常能想到的想法是找一个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 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
顺便说一下,最近我的blog反复被hack,搞得我很郁闷,因为是阿拉伯人或者是以色列人干的,所以没法沟通。
我还找不出来他们是怎么干的。
真的很郁闷。
好了。
接下来的日子里。我将再发布一些技术性的文章。突然感到这个位子很宝贵的说。
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 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
顺便说一下,最近我的blog反复被hack,搞得我很郁闷,因为是阿拉伯人或者是以色列人干的,所以没法沟通。
我还找不出来他们是怎么干的。
真的很郁闷。
好了。
接下来的日子里。我将再发布一些技术性的文章。突然感到这个位子很宝贵的说。
下一篇:asp下让数据库在需要读取的时候才打开第1/2页