在asp中导入excel表中多条数据,但需避免导入重复数据
例子:
服务器access中原有表products 的数据
id title price price2 huohao
1 三星手机 3500 3300 9508v
2 小米手机 3100 2800 4S
3 联想手机 3400 3200 8567
4 中兴手机 3600 3500 3C
exce上传的l数据
id 商品名称 卖价1 卖价2 货号
1 三星手机 3500 3300 9508v
2 ipone手机 4500 4400 5S
3 小米手机 3100 2800 4S
4 联想手机 3400 3200 8567
5 酷派手机 2200 2100 6452
6 中兴手机 3600 3500 3C
在下面这代码中的话,直接就把我excel数据全部导入了,在access中已有的数据重复去了。那么我应该在下面代码中加入什么才能让其只导入没有重复货号(红色标的没重)的商品。请高手帮忙。
<%
Set xlsconn = server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
source1=server.mappath("..")&"\"&replace(request("path"),"/","\")
myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &source1& ";Extended Properties=Excel 8.0"
xlsconn.open myConn_Xsl
sql="select * from [商品表格$]"
set rs=xlsconn.execute(sql)
if not rs.eof then
while not rs.eof
title=rs("商品名称")
price=rs("卖价1")
price2=rs("卖价2")
huohao=rs("货号")
sql="insert into [products](title,price,price2,huohao) values('"& title &"','"& price &"','"& price2 &"','"& huohao &"')"
conn.execute(sql)
rs.movenext
wend
end if
response.write "导入成功"
end if
%>