Originally just to play to write, did not expect to write after the constant questioning, so rewrite the code, perfect a bit, support the regular replacement, avoid the cause of the error of the binary (OLE object), and made an EXE program. Thanks for virtual help.
Attached ASP code:
Copy Code code as follows:
<%
'####################################
' Bulk Replace database contents 2008-3-17
' Replacement is irreversible, so make it back before operation
'####################################
Dim Db,conn,rs1,rs2,str1,str2,i,re
Str1= "admi[0-z]" ' String to replace, support regular
str2= "1234" replaced with a string
db= "Db.mdb" ' Database address
' The following need not be changed
' Create a 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 as not rs1.eof
If UCase (Rs1 ("Table_type")) = "Table" Then ' if it is a user table, action
Set rs2=server.createobject ("Adodb.recordset")
Rs2.open "SELECT * FROM [" &RS1 ("table_name") "]", conn,1,3
Do as 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 not automatically numbered and not 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 "Replace Complete"
' Custom substitution 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
%>