自己可以修改myreplace函数,实现复杂的替换.呵呵,好象用处不大.主要是看看如何读取access表和字段列表 ;% Q2 o( p+ x! P! z) Y0 E c3 p
'####################################
, P, ?. E, l. I7 z '替换数据库内容 lamking 2005-8-22
6 h- Q6 V1 W0 `: a( t& R8 a 'http://www.lamking.com QQ:6285578 q9 c) P) a$ ]% `: Q8 Q
'####################################
2 b; E" m* D$ ?4 z$ { Dim Db,Connstr,conn,rs,rs2,str1,str2,I; X. C, e I4 [
str1="abcd" '要替换的字符串; U d: m( a+ s1 f
str2="1234" '替换为的字符串: P5 `% b& d5 m6 p
Db="lamking.mdb"
0 w( ^; P( |$ L- o- i8 P1 \& d Set conn=Server.CreateObject("ADODB.Connection")
5 m, t/ p0 G* u4 G! [/ v ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="%26amp;server.mappath(Db): T( j$ D* s5 t/ u5 M# y1 V
Conn.Open ConnStr
# h6 N' K/ K3 M. V- n; ~ Set rs = conn.OpenSchema(20)- m" ?) x1 C! ~8 r* @' X* {
Do While Not rs.eof
6 }# R1 u, e/ t If rs("TABLE_TYPE")="TABLE" Then: T1 n3 c2 O! x' B3 Q3 A, ?- o
Set Rs2=Server.Createobject("adodb.recordset")
" j' o; |7 b2 O, R' \+ R" w Rs2.Open "select * from ["%26amp;rs("TABLE_NAME")%26amp;"]",conn,1,3. c, `# Q R* ?% R
Do While Not Rs2.Eof8 c S E7 s! ^# |4 S" w% h2 I0 z
For I=0 to Rs2.fields.count-17 t; d8 ~) U, E' x" Y6 t( s
If Rs2(i).Properties("ISAUTOINCREMENT") = False Then. @4 U% [- @# A+ D" a
Rs2(Rs2(i).name)=Myreplace(Rs2(i).value)9 W' D: M$ I* x3 q9 I% s( s# q
End If. D+ L) v" f ~+ C
Next
5 ?, g8 h- N/ M+ h5 p/ I Rs2.Movenext& ], U! f7 l% `
Loop% j1 n$ z) c& j8 K/ Y9 j
Rs2.Close
, O7 q5 i7 c- _/ L/ q Set Rs2=nothing# b0 U& Z; A' f9 S( A K0 O- h' z
End If& ]# Y! ?% N; I# I0 P
Rs.Movenext
+ F% s9 g& S5 T3 }' F3 M9 G Loop
% O% P" Y; z+ q! ]' M Rs.close& A# [0 L3 X- N, G
Set Rs=nothing+ Y7 q! C* t8 O h# E1 a+ m! T
Conn.close% {5 w. n- l3 f+ i
Set Conn=nothing
1 G5 C+ N$ r, y' F/ q Response.Write"替换完成"* l7 z# @" [; [' f0 M+ M
Function myreplace(byval Tstr)
* L* |" F# i- G: `+ H7 C a( n If Tstr="" Or isnull(Tstr) Then
- U/ s% }4 V& S' l8 b Exit Function7 _: i$ }' m- _ w
Else
' j- Q7 [8 c! J+ z myReplace=replace(Tstr,str1,str2)
# y* a6 y$ ]& z; G- s8 n7 M T1 C End If
# ~, F1 j& b! s1 l8 }4 a End Function
$ [3 E. N' N* X s' P3 V' ~ %; |