一个MDB中两个表的数据进行比较,重复的跳过,不重复的将表二中的数据加到表一中。以下代码怎么不行,请教。
<!--#INCLUDE file="conn.ASP"--><%
on error resume next
open_conn conn
set hrs=server.createobject("adodb.recordset")
hrs.open "select * from 表2 order by card asc",conn,1,3
For n=1 To hrs.recordcount
set ars=server.createobject("adodb.recordset")
ars.open "select * from 表1 where card='"&hrs("card")&"'",conn,1,3
If ars.recordcount=0 then
ars.close
set addrs=server.createobject("adodb.recordset") '提取爱酷数据
addrs.open "select * from 表1 where isnull(card)",conn,1,3
addrs.addnew
addrs("card")=hrs("card")
addrs("name")=hrs("name")
addrs("Cent")=hrs("Cent")
addrs("SumFare")=hrs("SumFare")
addrs("SumCent")=hrs("SumCent")
addrs.update
addrs.close
set addrs=nothing
ElseIf ars.recordcount=1 then
ars("Cent")=ars("Cent")+hrs("Cent")
ars("SumFare")=ars("SumFare")+hrs("SumFare")
ars("SumCent")=ars("SumCent")+hrs("SumCent")
addrs.update
End If
hrs.movenext
if hrs.eof or hrs.bof then exit For
Next
hrs.close
set hrs=nothing
Response.Write "<script language='JavaScript'>"
Response.write "alert('资料添加成功!');"
Response.Write "</script>"
%>