当前位置:编程学习 > asp >>

Asp问题,怎么批量替换access数据库里面的字符

我用一个采集程序采集回来的内容里面有“ ” 等字符,不能显示为“”,(采集程序有问题)已经入库了,我要把他替换掉,比如“替换成 “ ,要怎么替换啊,最好是做成asp文件,我传到空间,运行直接替换,我网上找了几个不会用,我菜鸟,请大家帮下我,谢谢了
答案:<%
Set Conn   = Server.CreateObject("ADODB.Connection")
Conn.Open  "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("数据库名.mdb")
Set rs = Server.Createobject("ADODB.Recordset")
sql="Select * from [表名]"
rs.open sql,conn,1,3
while not rs.eof
 rs("字段名")=replace(rs("字段名"),"“ ”","“")
 rs.update
 rs.movenext
wend
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
其他:replace

功能:在字串中查找,替代指定的字串.
格式:replace(strtobesearched,strsearchfor,strreplacewith [,start[,count[,compare]]])

参数:strtobesearched是字串; strsearchfor是被查找的子字串;strreplacewith 是用来替代的子字串.start,count,compare 是任意选项.

函数REPLACE()是最有用的字符串函数之一。你可以使用REPLACE()函数,以一个字符串取代另一个字符串的一部分。这里有一个例子:

<%

newuser=”Edwin c. Orr”

mystring=”Thank you,someone,for registering at our web site!”

mystring=REPLACE(mystring,”someone”,newuser)

%>

<%=mystring%>

在这个例子中,函数REPLACE()用来以一个站点访问者的名字替代表达式”someone”。该函数的返回值为”Thank you,Edwin c. Orr,for registering at our web site!”

上一个:对于MFC连接ACCESS数据库并在对话框中显示出来
下一个:懂ASP与access数据库的进

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,