A script I wrote a few years ago can automatically replace data in the entire database.
I just wrote it for fun at first, but I didn't expect that people would keep asking about it after I wrote it, so I rewrote the code and improved it. It supported regular replacement, avoided binary (ole objects) that would cause errors, and made an EXE. program. Thanks for the virtual help.
Attached asp code:
Copy the code as follows:<%
'###################################
'Batch replace database content 2008 -3-17
'Replacement is irreversible, so make a backup before operation
'############################### ####
Dim Db,conn,Rs1,Rs2,Str1,Str2,I,Re
str1=admi[0-z] 'String to be replaced, supports regular
str2=1234'String to be replaced
Db=db.mdb 'Database address
' No need to change the following
'Create regular object
Set Re=new RegExp
Re.IgnoreCase =True
Re.Global=True
Set Conn=Server.CreateObject(ADODB.Connection)
Conn.Open Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&server.mappath(Db)
Set Rs1 = Conn.OpenSchema(20)
Do While Not Rs1.Eof
If UCase( Rs1(TABLE_TYPE))=TABLE Then 'If it is a user table, perform the
Set
operationRs2=Server.Createobject(adodb.recordset)
Rs2.Open select * from [&Rs1(TABLE_NAME)],conn,1,3
Do While Not Rs2.Eof
For I=0 to Rs2.fields.count-1 'Traverse all fields
If Rs2(i).Properties(ISAUTOINCREMENT) = False And Rs2(i).Type<>128 And Rs2(i).Type<>204 And Rs2(i).Type<>205 Then 'If it is not an automatic number and it is not an ole object
Rs2(Rs2(i).name)=Myreplace(Rs2(i).value&)
End If
Next
Rs2.Movenext
Loop
Rs2.Close
Set Rs2=nothing
End If
Rs1.MoveNext
Loop
Rs1.Close
Set Rs1=Nothing
Conn.close
Set Conn=Nothing
Set Re=Nothing
Response.Write Replacement
completed'Customized replacement function
Function myreplace(byval Tstr)
If Tstr= Or isnull(Tstr) Then
Exit Function
Else
Re.Pattern=Str1
myReplace =Re.Replace(Tstr,Str2)
End If
End Function
%>