日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

asp代碼實(shí)現(xiàn)EXCEL數(shù)據(jù)導(dǎo)入到SQL數(shù)據(jù)庫(kù)

 gexian 2010-01-14
 
<html>
<head>
<title>上傳文件</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>
<script>
if (top.location==self.location)
{
    top.location="index.asp"
}
</script>
<body leftmargin="0" topmargin="0">
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<form name="form" method="post" action="readxls.asp" enctype="multipart/form-data">
    <tr>
          <td>
   <input name="file1" type=file class=input-text size="30">
  <input type=submit name="submit" value="導(dǎo)入數(shù)據(jù)" style="width:70px; height:19px;" >
         </td>
   </tr>
</form>
</table>
</body>
</html>
--------------------------------------
-------上傳并且寫(xiě)入庫(kù)-----------
readxls.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="upload_5xsoft.inc"-->
<!--#include file="common/db_conn.asp"--> 
<html xmlns="http://www./1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>EXECL數(shù)據(jù)導(dǎo)入</title>
<style type="text/css">
<!--
body,td,th {
 font-size: 12px;
 color: #666666;
}
-->
</style>
</head>
<body>
<%
session.CodePage=936
Server.ScriptTimeOut=600000
set upload=new upload_5xsoft
set file=upload.file("file1")
if file.fileSize>120000 then
%>
<script>
alert("您選擇的文件過(guò)大!");
window.close();
</script>
<% end if
if file.fileSize>0 then
    filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)
    filename=filename+"."
    filenameend=file.filename
    filenameend=split(filenameend,".")
    if filenameend(1)="xls" then
        filename=filename&filenameend(1)
        file.saveAs Server.mappath("uploadfile/"&filename)
    else
        response.write "數(shù)據(jù)格式不對(duì)!"
        response.write "<a href=upload.asp>返回</a>"
  response.end()
    end if
    set file=nothing
else
        response.write "文件不能為空!"
        response.write "<a href=upload.asp>返回</a>"
  response.end()
End if
set upload=nothing
'上傳XLS文件結(jié)束,下面從上傳的XLS文件中讀取數(shù)據(jù)寫(xiě)入到SQL數(shù)據(jù)庫(kù)
   strAddr=server.MapPath("uploadfile/"&filename)
   set excelconn=server.createobject("adodb.connection")
   excelconn.open "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = "+strAddr+";Extended Properties='Excel 8.0;HDR=NO;IMEX=1'"
 set rs=server.CreateObject("adodb.recordset")
 set rs1=server.CreateObject("adodb.recordset")
 sql="select * from [Sheet1$]"
 rs.open sql,excelconn,1,1
 if not(rs.bof and rs.eof) then
  rs.movenext
  do while not rs.eof
    sql1="select * from [Fees_Asse_T] where id is null"
    rs1.open sql1,conn,1,3
    rs1.addnew
       rs1("Cate_Code")=rs(0)
       rs1("Asse_Code")=rs(1)
       rs1("Asse_Name")=rs(2)
       rs1("Categories")=rs(3)
   rs1.update
   rs1.close
   rs.movenext
  loop
 end if
 rs.close() 
 set rs=nothing
 set rs1=nothing
 excelconn.Close()  
 set excelconn=nothing
 conn.close()
 set conn=nothing
%>
 <script>
   alert("數(shù)據(jù)導(dǎo)入成功!");
   window.parent.document.location.reload();
   history.back();
 </script>
</body>
</html>

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀(guān)點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多