Access generic-automatically replace strings in a database

Source: Internet
Author: User
access| Data | database | string

You can modify the Myreplace function to achieve complex substitutions. Oh, it seems to be of little use. Mainly to see how to Read Access tables and field lists

<%
'####################################
' Replace database content lamking 2005-8-22
' Http://www.lamking.com qq:628557
'####################################
Dim Db,connstr,conn,rs,rs2,str1,str2,i
str1= "ABCD" ' String to replace
str2= "1234" replaced with 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 as 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 as 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 "Replace Complete"
Function Myreplace (ByVal tstr)
If tstr= "" Or isnull (TSTR) Then
Exit Function
Else
Myreplace=replace (TSTR,STR1,STR2)
End If
End Function
%>




Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.