<%
Dim Db,conn,Rs1,Rs2,Str1,Str2,I,Re
str1="http://www.dgcoo.com/" '要替换的字符串,支持正则<font>
str2=http://www.yj8.com.cn/ '替换为的字符串
Db="YongJia.mdb" '这是你的数据库地址
table="Yj_Products" '这是要替换的数据库的表名称
ziduan="Content" '这是要替换的数据库的表的字段名称
'以下无需改动
'创建正则对象
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
Set Rs2=Server.Createobject("adodb.recordset")
Rs2.Open "select "& ziduan &" from "& table &"",conn,1,3
Do While Not Rs2.Eof
For I=0 to Rs2.fields.count-1 '遍历所有字段
Rs2(Rs2(i).name)=Myreplace(Rs2(i).value&"")
Next
Rs2.Movenext
Loop
Rs2.Close
Set Rs2=nothing
Rs1.MoveNext
Loop
Rs1.Close
Set Rs1=Nothing
Conn.close
Set Conn=Nothing
Set Re=Nothing
response.write " <font color=’#ff3300′><b>替换数据成功!</b></font>"
'自定义的替换函数
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
%> |