ASP implementation to import the contents of one database into another database

Source: Internet
Author: User
Tags db2 sql injection
During the construction of the website, it is often necessary to import the data from the original database into the new database, and the field name is different. If the volume is small, you can copy, if the volume is large, is very troublesome things, now only need such a piece of code can be achieved.

<%
Dim STARTIME,CONN1,CONN2,CONNSTR1,CONNSTR2,DB1,DB2
Startime=timer ()
db1= "A.mdb" Database 1
db2= "B.mdb" Database 2
On Error Resume Next ' tries to connect to the database until timeout, but can enhance SQL injection filtering
CONNSTR1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DB1)
CONNSTR2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DB2)
Set Conn1=server.createobject ("ADODB. CONNECTION ")
Set Conn2=server.createobject ("ADODB. CONNECTION ")
Conn1. Open CONNSTR1
Conn2.open CONNSTR2

Dim rs1,rs2
Set Rs1 = Conn1.execute ("select * from [[a] [table]]")
Do as not rs1.eof

Set Rs2 = Server.CreateObject ("ADODB. Recordset ")
SQL2 = "SELECT * from [a table in B library]"
Rs2.open sql2,conn2,1,3,1
Rs2.addnew
Rs2 ("Field 1 of library B") = Rs1 ("Field a library 1")
Rs2 ("Field 2 of library B") = Rs1 ("Field a library 2")
......
Rs2.update

Rs1.movenext
Loop
Response.Write "Operation succeeded"
Response.End
%>



Related Article

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.