%
'####################################
'替換數(shù)據(jù)庫內(nèi)容 lamking 2005-8-22
'更新修正:2006-6-28
'http://www.imbbs.cn QQ:628557
'出售空間域名。網(wǎng)頁制作。
'####################################
'以下請根據(jù)你的不同情況做修改
Const S1="admin" '要被替換的字符串
Const S2="1234" '替換為的字符串
Const Db="lamking.mdb" '數(shù)據(jù)庫
Const IgnoreCase=True '忽略大小寫
'以下數(shù)據(jù)無需更改
Dim oRs,oRs2,conn,I
Set conn=Server.CreateObject("Adodb.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="server.mappath(Db)
Set oRs=conn.OpenSchema(20)
Do While not oRs.Eof
If Ucase(oRs("TABLE_TYPE"))="TABLE" Then '如果是用戶表
'循環(huán)替換該表的每一個字段
Set oRs2=Server.CreateObject("Adodb.RecordSet")
oRs2.Open "select * from ["ors("TABLE_NAME")"]",conn,1,3
Do While Not oRs2.Eof
For I=0 To oRs2.Fields.Count-1
'如果是OLE對象或者自動編號字段,則不替換
If oRs2(I).Properties("ISAUTOINCREMENT")=False And ors2(I).type>205 Then
oRs2(oRs2(I).Name)=MyReplace(oRs2(I).value)
End If
Next
oRs2.update
oRs2.MoveNext
Loop
oRs2.close
set oRs2=Nothing
End If
oRs.Movenext
Loop
oRs.close
Set oRs=nothing
Conn.close
Set Conn=nothing
Response.Write"替換完成"
Function myreplace(byval Tstr)
Dim RegEx
If Tstr="" Or isnull(Tstr) Then Exit Function
Set RegEx=New RegExp
RegEx.Global = True
RegEx.IgnoreCase = IgnoreCase
RegEx.MultiLine = True
RegEx.Pattern=S1
myReplace=RegEx.Replace(TStr,S2)
Set RegEx=Nothing
End Function
%>