<%'sql 连接驱动
dim conn,connstr,time1,time2,mdb
time1=timer
dim aa
aa=request.form("EXCEL")
'获取传递过来的值
Dim
StrConnect,cc
Dim
objConn
Dim
rs
Dim
Sql
cc=0
'Excel连接驱动
aaa="provider=Microsoft.Jet.OLEDB.4.0; Data Source="&aa&";Extended Properties=Excel 8.0"
set StrConnect=CreateObject("ADODB.Connection")
StrConnect.Open aaa
Set objConn=CreateObject("ADODB.Connection")
objConn.Open
StrConnect
'注意 表名一定要以下边这种格试"[表名$]"书写
Set
rs = Server.CreateObject("ADODB.Recordset")
Sql="select * from [sheet1$]"
rs.Open
Sql,StrConnect,2,2
IF
rs.Eof And Rs.Bof
Then
response.Write("<script>alert('没有资料可以导入!');history.go(-1)</script>")
else
Do While
Not rs.EOF
if rs(0)<>""
then
'插入SQL2000里
set rssql=server.CreateObject("adodb.recordset")
rssql.Open "select * from a_sell where PartNo='"&rs(0)&"'",conn,1,3
if not rssql.recordcount=0 then
response.write ""
else
rssql.AddNew
rssql(1)=rs(0)
rssql(2)=rs(1)
rssql(3)=rs(2)
rssql(4)=rs(3)
rssql(5)=rs(4)
rssql(6)=rs(5)
rssql(7)=rs(6)
rssql(8)=rs(7)
rssql.Update
end if
end if
Rs.MoveNext
Loop
end if
response.Write"<script language=javascript>alert('资料导入成功!\n重复数据未导入');history.go(-1)</script>"
%>