Common Access -- automatically replaces strings in the database
Source: Internet
Author: User
You can modify the myreplace function to implement complicated replacement. It seems to be of little use. It mainly refers to how to read the access table and field list.
<%
'####################################
'Replacing the database content with lamking
'Http: // www.lamking.com QQ: 628557
'####################################
Dim Db, Connstr, conn, rs, rs2, str1, str2, I
Str1 = "abcd" 'string to be replaced
Str2 = "1234" 'replaced by a string
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 "replaced"
Function myreplace (byval Tstr)
If Tstr = "" Or isnull (Tstr) Then
Exit Function
Else
MyReplace = replace (Tstr, str1, str2)
End If
End Function
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.