从不同数据中某个表中读取多条记录批量写入另一个数据库某个表?
从不同数据中某个表中读取多条记录批量写入另一个数据库某个表
------解决方案--------------------建二个不同的库名和记录集就可以了
比如
DB_name= "DBQ= "+server.mappath( "db1.mdb ")+ ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};userid=administrator;password=111111; "
set conn1=server.createobject( "ADODB.CONNECTION ")
conn1.open DB_name
DB_name= "DBQ= "+server.mappath( "db2.mdb ")+ ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};userid=administrator;password=111111; "
set conn2=server.createobject( "ADODB.CONNECTION ")
conn2.open DB_name
Sql= "SELECT * from aaa "
Set rs1=Server.CreateObject( "ADODB.RecordSet ")
rs1.Open Sql,conn1,1,3
Sql= "SELECT * from bbb "
Set rs2=Server.CreateObject( "ADODB.RecordSet ")
rs2.Open Sql,conn2,1,3
for n=1 to rs1.recordcount
rs2.addnew
for m=0 to rs2.Fields.Count-1 '只能是字段个数相同的,并且是一一对应的,如不同请根据字段一一写出.
rs2(m)=rs1(m)
next
rs1.movenext
next