Access通用-自動替換數(shù)據(jù)庫中的字符串:
自己可以修改myreplace函數(shù),實現(xiàn)復雜的替換.呵呵,好象用處不大.主要是看看如何讀取access表和字段列表
<%
'####################################
'替換數(shù)據(jù)庫內(nèi)容 lamking 2005-8-22
'http://www.lamking.com QQ:628557
'####################################
Dim Db,Connstr,conn,rs,rs2,str1,str2,I
str1="abcd" '要替換的字符串
str2="1234" '替換為的字符串
Db="lamking.mdb"
Set conn=Server.CreateObject("ADODB.Connection")
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath(Db)
Conn.Open ConnStr
Set rs = conn.OpenSchema(20)
Do While Not rs.eof
If rs("TABLE_TYPE")="TABLE" Then
Set Rs2=Server.Createobject("adodb.recordset")
Rs2.Open "select * from ["&rs("TABLE_NAME")&"]",conn,1,3
Do While Not Rs2.Eof
For I=0 to Rs2.fields.count-1
If Rs2(i).Properties("ISAUTOINCREMENT") = False Then
Rs2(Rs2(i).name)=Myreplace(Rs2(i).value)
End If
Next
Rs2.Movenext
Loop
Rs2.Close
Set Rs2=nothing
End If
Rs.Movenext
Loop
Rs.close
Set Rs=nothing
Conn.close
Set Conn=nothing
Response.Write"替換完成"
Function myreplace(byval Tstr)
If Tstr="" Or isnull(Tstr) Then
Exit Function
Else
myReplace=replace(Tstr,str1,str2)
End If
End Function
%>
更多信息請查看IT技術專欄