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
%>