请高手帮忙,虑遍一个字段然后把中间的,某些值替换为另外的值……
请高手帮忙,虑遍一个字段然后把中间的,某些值替换为另外的值……
自己写了一段很垃圾的代码,新手望大家指导。
Function.asp 文件
<%
'------------------------------------------------------------打开数据库部分
Dim Conn,Connstr,Rs
Sub DataStr(DString)
if DString="open" then
On Error Resume Next
Set Conn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="&Server.MapPath("445454554.mdb")&";DRIVER={Microsoft Access Driver (*.mdb)};"
Set Rs=Server.CreateObject("ADODB.Recordset")
Conn.open Connstr
if Err then
Set Conn=Nothing
Err.Clear
Response.Write("连接数据库错误!")
Response.End
End if
End if
'--------------------------------------------------------------关闭数据库部分
if DString="close" then
Conn.Close
Set Conn=Nothing
Set Rs=Nothing
End if
End Sub
'--------------------------------------------------------------结束Sub DataStr()
%>
replace.asp 文件
<!--#include file="Function.asp"-->
<%
Server.ScriptTimeout = 150
Call DataStr("open")
Dim Myrs,GetValue
rs.open("Select body from Dv_bbs1 order by AnnounceID desc"),conn,1,3
Myrs=rs("Body")
if Not rs.eof then
for i = 1 to rs.recordcount
GetValue=Replace(Myrs,"[/upimg]","[/IMG]")
rs("Body")=GetValue
rs.update
rs.movenext
if rs.eof then Exit for
next
End if
Response.Write("<Script>alert(""修改成功"")</script>")
Response.End
Call DataStr("close")
%>
思路好像错了,望大家能提供一种好的方法给我。谢谢