Access generic-automatically replaces strings in a database

Source: Internet
Author: User

  Access generic-automatically replace strings in a database:

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

<% 
' #################################### 
' replaces the contents of the database lamking 2005-8-22 
' http://www.lamking.com QQ : 628557 
' #################################### 
Dim db,connstr,conn,rs,rs2,str1,str2,i 
str1= "ABCD" to replace the string  
str2= "1234" replaced by a string  
db= "Lamking.mdb" &NBSP;
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 ( )
do, not rs.eof 
If rs ("table_type") = "TABLE" THEN&NBSP;
Set rs2= Server.CreateObject ("Adodb.recordset")  
Rs2.open "select * FROM [" &rs ("table_name") & "]", conn,1,3 &NBSP
Do, 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 &NBSP
Set rs2=nothing 
End if 
rs.movenext 
loop 
rs.close 
Set rs= NOTHING&NBSP
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.