新微赢技术网

标题: (新手求助)ASP中比较二服务器表1和表2中的数据差异,删除表1中多于表2的数 ... [打印本页]

作者: 黑侠    时间: 2010-1-11 01:44
标题: (新手求助)ASP中比较二服务器表1和表2中的数据差异,删除表1中多于表2的数 ...
<%set conn1=server.createobject("adodb.connection")
    strConn1 = "Provider=Sqloledb;User ID=sa;Password=123;Initial Catalog=web;Data Source=(local)"
Conn1.open strConn1   
set rs1=server.createobject("adodb.recordset")
rs1.open "Select * From 表1",Conn,0,1

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

rs1.close
set rs1=nothing
%>




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2