t1=rs1("name")
do while not rs1.eof
%> <%
set conn2=server.createobject("adodb.connection")
strConn2 = "Provider=Sqloledb;User ID=sa;Password=123;Initial Catalog=web;Data Source=192.168.0.1"
Conn2.open strConn2
set rs2=server.createobject("adodb.recordset")
rs2.Open "Select * from 表2 where name='"&t1&"'",conn2,1,1
if rs2.eof then
conn1.Execute("delete 表1 where name='"&t1&"'")
end if
ors.MoveNext
loop
rs1.close
set rs1=nothing
%>
大概就是这样:我想本机数据库中的,表1中name字断依依在另台服务器上表2中查询是否有此数据,如果没有那就删除表1中的数据!!!!
我上面的代码无报错,但无效果,请高手指点下作者: √死胖子 时间: 2010-1-11 01:44
<%
set conn1=server.createobject("adodb.connection")
strConn1 = "Provider=Sqloledb;User ID=sa;Password=123;Initial Catalog=web;Data Source=(local)"
Conn1.open strConn1
set conn2=server.createobject("adodb.connection")
strConn2 = "Provider=Sqloledb;User ID=sa;Password=123;Initial Catalog=web;Data Source=192.168.0.1"
Conn2.open strConn2
set rs1=server.createobject("adodb.recordset")
rs1.open "Select * From 表1",Conn1,0,1
do while not rs1.eof
t1=rs1("name")
set rs2=server.createobject("adodb.recordset")
rs2.Open "Select * from 表2 where name='"&t1&"'",Conn2,1,1
if Not rs2.eof then
conn1.Execute("delete 表1 where name='"&t1&"'")
end if
rs1.MoveNext
loop