asp 比较二个数据库

来源:百度知道 编辑:UC知道 时间:2024/09/19 16:15:50
set conn1=server.createobject("adodb.connection")
set conn2=server.createobject("adodb.connection")
strConn1 = "Provider=Sqloledb;User ID=web;Password=888;Initial Catalog=web;Data Source=192.168.0.1"
strConn2 = "Provider=Sqloledb;User ID=web;Password=888;Initial Catalog=web;Data Source=192.168.0.1"
Conn1.open strConn1
Conn2.open strConn2
set rs1=server.createobject("adodb.recordset")
rs1.open "Select * From 表1",Conn,0,1

t1=rs1.Fields("name").Value
do while not rs1.eof
set rs2=server.createobject("adodb.recordset")
rs2.open "Select * From 表2 where name="&t1&"",Conn,0,1
if rs2.eof then
rs1.Open"delete 表1 where name='"&t1&"'",conn,0,1
else
end if
rs1.movenext
loop
rs1.close
rs2.close

我想让表1中的数据依次在表2中查询,如果查询不到,那么删除表1中的数据

我是新手。。只有这点分

t1=rs1("name")
do while not rs1.eof
set rs2=server.createobject("adodb.recordset")
rs2.open "Select * From 表2 where name='"&t1&"'",Conn,1,1
if rs2.eof then
conn1.execute("delete * from 表1 where name='"&t1&"'")
end if
rs1.movenext
loop
rs1.close
rs2.close