asp+Access 从一个数据库里提取 写进另一个数据库 50
<%Dimstartime,conn1,conn2,connstr1,connstr2,db1,db2startime=timer()db1="../date/date....
<%
Dim startime,conn1,conn2,connstr1,connstr2,db1,db2
startime=timer()
db1="../date/date.mdb" '数据库1
db2="../../cha/DataBase/db.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 [user] where len(zf)>0")
Do While Not Rs1.Eof
Set Rs2 = Server.CreateObject("ADODB.Recordset")
Sql2 = "Select * From [Staff]"
Rs2.Open SQL2,Conn2,1,3,1
'if not (Rs2("name") = rs1("un") and Rs2("sid") =rs1("id")) then 这五行是我加的代码
' Response.Write Rs2.Addnew 想检查db2里是否有姓名和学号都相同的记录
'else 如果没有就加入新记录
' Response.Write 如果有就改写原记录的某些
'end if 结果不成功!
Rs2.Addnew
Rs2("name") = rs1("un")
Rs2("sid") =rs1("id")
Rs2("bs") ="永久"
Rs2("cate") ="1"
Rs2("sj") = rs1("sr")
Rs2("source") =Date()
Rs2("dep") = rs1("xx")
Rs2("cname") = rs1("email")
Rs2.Update
Rs1.MoveNext
Loop
Response.Write "操作成功"
Response.End
%>
要更多的分可以商量的哟! 展开
Dim startime,conn1,conn2,connstr1,connstr2,db1,db2
startime=timer()
db1="../date/date.mdb" '数据库1
db2="../../cha/DataBase/db.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 [user] where len(zf)>0")
Do While Not Rs1.Eof
Set Rs2 = Server.CreateObject("ADODB.Recordset")
Sql2 = "Select * From [Staff]"
Rs2.Open SQL2,Conn2,1,3,1
'if not (Rs2("name") = rs1("un") and Rs2("sid") =rs1("id")) then 这五行是我加的代码
' Response.Write Rs2.Addnew 想检查db2里是否有姓名和学号都相同的记录
'else 如果没有就加入新记录
' Response.Write 如果有就改写原记录的某些
'end if 结果不成功!
Rs2.Addnew
Rs2("name") = rs1("un")
Rs2("sid") =rs1("id")
Rs2("bs") ="永久"
Rs2("cate") ="1"
Rs2("sj") = rs1("sr")
Rs2("source") =Date()
Rs2("dep") = rs1("xx")
Rs2("cname") = rs1("email")
Rs2.Update
Rs1.MoveNext
Loop
Response.Write "操作成功"
Response.End
%>
要更多的分可以商量的哟! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询