ASP代碼實現自動清除替換ACCESS(MDB)資料庫的日文字元的

來源:互聯網
上載者:User

此時我們通常能想到的想法是找一個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,搞得我很鬱悶,因為是阿拉伯人或者是以色列人乾的,所以沒法溝通。
我還找不出來他們是怎麼乾的。
真的很鬱悶。
好了。
接下來的日子裡。我將再發布一些技術性的文章。突然感到這個位子很寶貴的說。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.