JavaScrip Zone


新发表

新评论

留言信息

链接收藏

『中国群落博客』

免费注册博客通道

快速登陆


自动替换ACCES数据库中的字符串

自己可以修改myreplace函数,实现复杂的替换.呵呵,好象用处不大.主要是看看如何读取access表和字段列表

<%
'####################################
'替换数据库内容 lamking 2005-8-22
'http://www.lamking.com QQ:628557
'####################################
Dim Db,Connstr,conn,rs,rs2,str1,str2,I
str1="abcd" '要替换的字符串
str2="1234" '替换为的字符串
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"替换完成"
Function myreplace(byval Tstr)
If Tstr="" Or isnull(Tstr) Then
 Exit Function
Else
 myReplace=replace(Tstr,str1,str2)
End If
End Function
%>


                                                                 2005-10-26 17:40:31

Posted by jser | 阅读全文() | 回复(0) | 引用通告() | 编辑

..................................................
博客的精神于写自己某一刻的思想或心动!
..................................................
当然要是你愿意就是拿来做记事本也可以!
..................................................
群落博客将提供全程免费服务!免费注册!
..................................................
欢迎您成为群落博客的成员!使用之前请先看系统帮助>>>>系统帮助
..................................................

免费注册群落博客【点击完成注册】
..................................................

发表评论:

    昵称:
    密码: (游客无须输入密码)
    主页:
    标题: