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
%>