Replace database content

Source: Internet
Author: User

<%
'############################### #####
'replace the database content with lamking
'update and fix:
'HTTP: // www.imbbs.cn QQ: 628557
'sale space domain name. Create a Web page.
'####################################
'modify the following according to your situation
const S1 = "admin" 'string to be replaced
replace const S2 = "1234"' string
const DB = "lamking. mdb "'database
const ignorecase = true' case-insensitive
'the following data does not need to be changed
dim ors, ors2, Conn, I
set conn = server. createobject ("ADODB. connection ")
Conn. open "provider = Microsoft. jet. oledb.4.0; Data Source = "& server. mappath (db)
set ors = Conn. openschema (20)
do while not ORS. EOF
If ucase (ORS ("table_type ")) = "table" then' if it is a user table
', each field of the table is replaced cyclically.
set ors2 = server. createobject ("ADODB. recordset ")
ors2.open" select * from ["& Ors (" table_name ") &"] ", Conn, 1, 3
do while not ors2.eof
for I = 0 to ors2.fields. count-1
'if it is an OLE object or an automatically numbered field, it is not replaced.
If ors2 (I ). properties ("isautoincrement") = false and ors2 (I ). type <> 205 then
ors2 (ors2 (I ). name) = myreplace (ors2 (I ). value)
end if

Next
Ors2.update
Ors2.movenext
Loop
Ors2.close
Set ors2 = nothing
End if
ORS. movenext
Loop
ORS. Close
Set ors = nothing
Conn. Close
Set conn = nothing
Response. Write "replaced"

Function myreplace (byval tstr)
Dim RegEx
If tstr = "" Or isnull (tstr) Then exit function
Set RegEx = new Regexp
RegEx. Global = true
RegEx. ignorecase = ignorecase
RegEx. multiline = true
RegEx. pattern = S1
Myreplace = RegEx. Replace (tstr, S2)
Set RegEx = nothing
End Function
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.