专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »Asp教程 » asp导入excel:ASP数据导入进度 »正文

asp导入excel:ASP数据导入进度

来源: 发布时间:星期四, 2008年9月25日 浏览:402次 评论:0
一直想写个ASP数据导入进度的实例,今天终于写好了,发出来给大家看看,写的不好多保护啊,呵呵。
<!--#includefile=\"inc/dsn.asp\"-->
<!--#includefile=\"inc/vbfun.asp\"-->
<formname=\"data\"action=\"\"id=\"data\">
<inputname=\"showdata\"type=\"text\"value=\"数据加载中...\"size=\"100\">
</form>
<script>
<%
excelurl=request.Form(\"file_url\")
gz_year=request.Form(\"gz_year\")
gz_month=request.Form(\"gz_month\")
ifgz_year=\"\"then
gz_year=year(now())
endif
ifgz_month=\"\"then
gz_month=month(now())
endif
ifexcelurl<>\"\"then
setrs=server.CreateObject(\"adodb.recordset\")
strexcel=\"provider=Microsoft.Jet.OLEDB.4.0;DataSource=\"&server.MapPath(excelurl)&\";ExtendedProperties=Excel8.0\"
setconnexcel=CreateObject(\"ADODB.Connection\")
connexcel.Openstrexcel
Sql=\"select*from[sheet1$]\"
rs.OpenSql,connexcel
IFrs.EofAndRs.BofThen
response.Write(\"alert(’没有资料可以导入!’);\")
else
Conn.BeginTrans
setrsf=server.CreateObject(\"adodb.recordset\")
rsf.open(\"select*fromgz_inforwheregz_year=\"&gz_year&\"andgz_month=\"&gz_month&\"\"),conn
ifnotrsf.eofthen
response.write\"alert(’在这个月中您已经导入了一次工资以免重复请核对,该次操作作废!’);</script>\"
response.End()
endif
dowhilenotrs.eof
%>
document.data.showdata.value=\"<%=\"用户名:\"&rs(1)&\"账号:\"&rs(0)%>\";
<%
process=rs(0)
’OnErrorResumeNext
conn.execute(\"importgz’\"&rs(0)&\"’,’\"&rs(1)&\"’,’\"&rs(2)&\"’,’\"&rs(3)&\"’,’\"&rs(4)&\"’,’\"&rs(5)&\"’,’\"&rs(6)&\"’,’\"&rs(7)&\"’,’\"&rs(8)&\"’,’\"&rs(9)&\"’,’\"&rs(10)&\"’,’\"&rs(11)&\"’,’\"&rs(12)&\"’,’\"&rs(13)&\"’,’\"&rs(14)&\"’,’\"&rs(15)&\"’,’\"&rs(16)&\"’,’\"&rs(17)&\"’,\"&gz_year&\",\"&gz_month)
ifconn.Errors.Count>0then
conn.Errors.Clear [Page]
conn.RollBackTrans
response.write\"<script>alert(导入过程中出现错误,该次操作作废!’);history.back();</Script>\"
response.End()
endif
rs.movenext
loop
Conn.CommitTrans
response.Write(\"alert(’成功导入用户资料’);\")
endif

%>
document.data.showdata.value=\"数据导入完毕\";
<%
else
%>
window.alert(\"你没有选择任何文件\");
document.data.showdata.value=\"你没有选择任何文件\";
<%
endif
%>
</script>
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: