对过万条数据的数据库字段内容批量替换程序

该程序是针对非常庞大的数据库开发的,没有用循环
用途:
     对过万条数据的数据库字段内容批量替换
代码: <% '//数据库连接     Dim BeeYee_DbName,Connstr,Conn,intSn1     Dim Content,Num,intSn,intIdNo,strCodea,strCodec,Rs,strSql
    Server.ScriptTimeOut = 800
    BeeYee_DbName="transfer"         '修改此处为你的SQL Server 数据库名称
    YourServer = "seven"       '修改此处为你的Sql Server数据库地址
    YourUid  = "sa"                   '修改此处为你的数据库用户名
    YourPassword = "123"           '修改此处为你的数据库密码    
    Connstr = "Driver={SQL Server};Server="&YourServer&";Uid="&YourUid&";Pwd="&YourPassword&";Database="&BeeYee_DbName
    Set Conn=Server.CreateObject("ADODB.CONNECTION")
    On Error Resume Next
    Conn.Open Connstr
    If Err<>0 Then
        err.Clear
        Set Conn = Nothing
        Response.Write "<div align=center><br><br><br>连接SqlServer数据库出错,请检查相关设置……</div>"
        Response.End   
    End If
'//数据处理部分
    intSn = Request("Sn")
    intIdNo = Request("IdNo")
    If intSn = "" Or Not isNumeric(intSn) Then
        intSn = 0
        intSn1 = 0
    Else
        intSn = CLng(intSn)
        intSn1 = intSn
    End If
    If intIdNo = "" Or Not isNumeric(intIdNo) Then
        intIdNo = 0
    Else
        intIdNo = CLng(intIdNo)
    End If
    strCodea="/newe"                                    '//需要查询是否包含的字符串
    strCodeb="/news"                '//替换字符串
    strSql = "Select Top 1 Id,Content,Uptime From News where id>"&intIdNo&" And siteid=1 order by id"
    Set Rs = Server.CreateObject("adodb.recordset")
    Rs.Open strSql,conn,1,3
    If not(rs.eof oR rs.bof) then
        Content = Rs("content")
        Num = instr(content,strCodea)
        If Num>0 then           
            Content=Replace(content,strCodea,strCodeb)   
            Rs("Content") = Content
            Rs("Uptime") = now()
            Rs.Update
            intSn = intSn + 1
        End If
        intIdNo = Rs("Id")
        Rs.Close
        Set Rs = Nothing
        Response.Write("<br><br><br><Div align=center>正在转换第<font color=red>"&intSn&"</font>条新闻....</Div>")
        If intSn = intSn1 Then Response.Write("<br><br><br><Div align=center>新闻中没有要转换的东西,程序继续转换下一篇</Div>")
        Response.write("<meta http-equiv=""refresh"" content=""0;url=?Sn="&intSn&"&IdNo="&intIdNo&""">")
    Else
        Response.write("<br><br><br><Div align=center>转换完毕!!共转换<font color=red>"&intSn&"</font>条新闻.</Div>")
        Rs.Close
        Set Rs = Nothing
        Response.End()
    End If  
%>
posted @ 2006-11-07 20:57  已經停更  阅读(534)  评论(0编辑  收藏  举报