日期:2010-01-22 浏览次数:20916 次
<%
Dim startime,conn1,conn2,connstr1,connstr2,db1,db2
startime=timer()
db1="a.mdb" '数据库1
db2="b.mdb" '数据库2
on error resume next '尝试连数据库,一直到超时,但可以加强SQL注入过滤
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库的某表]")
Do While Not Rs1.Eof
Set Rs2 = Server.CreateObject("ADODB.Recordset")
Sql2 = "Select * From [b库的某表]"
Rs2.Open SQL2,Conn2,1,3,1
Rs2.Addnew
Rs2("b库的字段1") = rs1("a库的字段1")
Rs2("b库的字段2") = rs1("a库的字段2")
......
Rs2.Update
Rs1.MoveNext
Loop
Response.Write "操作成功"
Response.End
%>