Access通用-自动替换数据库中的字符串

2016-01-29 18:55 70 1 收藏

Access通用-自动替换数据库中的字符串,Access通用-自动替换数据库中的字符串

【 tulaoshi.com - ASP 】

 

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

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

<%
'####################################
'替换数据库内容 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
%

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/) 

来源:https://www.tulaoshi.com/n/20160129/1507810.html

延伸阅读
标签: 办公软件
Word共享Access数据最简单的方法是复制、粘贴,你只需打开Access数据库中的表,就可以像复制Excel数据那样复制Access数据然后粘贴到Word中。另外,Word还可以使用插入记录的方法共享Access、SQL数据。 1、插入全部记录 右键单击Word工具栏,选择“数据库”命令,打开“数据库”工具栏,单击“插入数据库”按钮,在打开的“数据库”...
核心语句: UPDATE `cdb_pms` SET `subject` = REPLACE(`subject`, 'Welcome to', '欢迎光临') mysql替换字段里数据内容部分字符串 mysql替换表的字段里面内容,如例子: mysql select host,user from user  where user='testuser'; +-----------------------+----------+ | host       &nbs...
FillString函数有两个参数,一个是用来重复填充的字符,另一个是填充后的字符串长度。然后它返回填充后的字符串,重复次数由填充字符的个数和填充后字符串长度决定。 该函数建立一个循环,循环次数基于所要求的字符串长度。循环步长有参数Value(即用来重复填充的子字符串)的长度决定。该函数把参数Value作为工作字符串,重复后按所要...
Deleting all data from an Access database Sometimes it may be necessary to delete all the data in a database while retaining the table structure. If done manually, this job can quickly become tedious. If your database has many tables, the following code will clear all the data in a hurry. Dim ctr As Container, d...
基本要求:需安装WORD FunctionWordReplace(FileNameAsString,SearchStringAsString,ReplaceStringAsString,OptionalSaveFileAsString="",OptionalMatchCaseAsBoolean=False)AsInteger OnErrorGoToErrorMsg'函数运行时发生遇外或错误,转向错误提示信息 DimwordAppAsNewWord.Application DimwordDocAsNewWord.Docu...

经验教程

928

收藏

45
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部