<%
dim strdb
dim str_Xsl,myConn_Xsl,filename
filename=trim(request.Form("filename"))
strdb=server.MapPath("uploadfiles/"&filename&"")
set rsXsl=Server.Createobject("ADODB.Recordset")
set myConnection=server.createobject("adodb.connection")
myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &strdb&";Extended Properties=Excel 8.0"
myconnection.open myConn_Xsl
str_Xsl="select * from [sheet1$]"
rsXsl.open str_Xsl,myconnection,1,1
if not(rsXsl.eof and rsXsl.bof) then
sql="select * from ks where snum='"&rsXsl(1)&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof then
do while not rsXsl.eof
rs.addnew
rs("sno")=rsXsl(0)
rs("snum")=rsXsl(1)
rs("sname")=rsXsl(2)
rs("ssex")=rsXsl(3)
rs("sks")=rsXsl(4)
rs.update
rsXsl.movenext
loop
else
response.write "数据已存在!或添加成功,请<a href='admin_ks.asp'>查看</a>"
response.end
end if
response.write "数据导入成功!"
rsXsl.close
set rsXsl=nothing
myconnection.close
else
response.write "Excel表不存在,或记录为空"
end if
%>