This program is developed for a very large database and does not use loops.
Purpose:
Batch Replace the content of database fields with tens of thousands of data entries
Code:
<%
'// Database connection
Dim BeeYee_DbName, Connstr, Conn, intSn1
Dim Content, Num, intSn, intIdNo, strCodea, strCodec, Rs, strSql
Server. ScriptTimeOut = 800
BeeYee_DbName = "transfer" 'modify the name of your SQL Server database.
YourServer = "seven" 'modify the address of your SQL Server database here
YourUid = "sa" 'modify your database user name here
YourPassword = "123" 'modify your database password here
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> An error occurred while connecting to the SqlServer database. Check the related settings ...... </Div>"
Response. End
End If
'// Data Processing Section
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" '// You Need to query whether the string is contained.
StrCodeb = "/news" '// Replace the string
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> <Div align = center> converting <font color = red>" & intSn & "</font> News .. .. </Div> ")
If intSn = intSn1 Then Response. write ("<br> <Div align = center> there is no conversion in the news, and the program continues to convert the next article </Div> ")
Response. write ("<meta http-equiv =" "refresh" "content =" "0; url =? Sn = "& intSn &" & IdNo = "& intIdNo &" "> ")
Else
Response. write ("<br> <Div align = center> Switch complete !! <Font color = red> "& intSn &" </font> News. </Div> ")
Rs. Close
Set Rs = Nothing
Response. End ()
End If
%>