<%
'###################################################################
'Replace database content lamking 2005-8-22
'Updated and revised: 2006-6-28
'http://www.imbbs.cn QQ:628557
'Sold space domain name. Web page production.
'###################################################################
'Please make changes to your different situations
Const S1="admin" 'The string to be replaced
Const S2="1234" 'Replaced with string
Const Db="lamking.mdb" 'Database
Const IgnoreCase=True 'Ignore case
'The following data does not need to be changed
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 'If it is a user table
'Loop replaces each field of the table
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
'If it is an OLE object or an automatic numbering field, it will not be replaced
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 "Replacement Completed"
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
%>