Tc711Com提示:execl 批量导入 access asp 实例源码 |
<%
DB="db1.mdb"
path=Server.MapPath(DB)
set conn=server.createobject("adodb.Connection")
connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source="&path
conn.Open connstr
Set rs=server.CreateObject("adodb.recordset")
'连接excel数据库
path="./"
Dim xlsconn,strsource,xlbook,xlsheet,i
Dim myConn_Xsl,xlsrs,sql,objCmd
Set xlsconn = server.CreateObject("adodb.connection")
Set xlsrs = Server.CreateObject("Adodb.RecordSet")
filename="商品"
file2="商品列表"
source=server.mappath(path&filename&".xls")
myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &source& ";Extended Properties=Excel 8.0"
xlsconn.open myConn_Xsl
sql = "Select * from ["&file2&"$]"
xlsrs.open sql,xlsconn,1,1
If xlsrs.eof Then
else
i=1
response.write "<TABLE border=1>"
Do While not xlsrs.eof
goods_name=xlsrs("商品名")
goods_images=xlsrs("图片")
cat_id=xlsrs("商品分类")
%>
<TR>
<TD> <%=goods_name%></TD>
<TD> <%=goods_images%></TD>
<TD> <%=cat_id%></TD>
</TR>
<%
sql="insert into goods(goods_name,goods_images,cat_id) values('"&goods_name&"','"&goods_images&"',"&cat_id&")"
conn.execute(sql)
i=i+1
xlsrs.MoveNext
Loop
response.write "</table>"
End If
xlsrs.close
Response.write "共导入<font color='red'>" & i-1 & "</font>条记录.<br>" & vbCrLf
set xlsconn=nothing
set objCmd=nothing
%>
实例下载: http://bbs.tc711.com/thread-7012-1-1.html
更多的execl 批量导入 access asp 实例源码请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2012-7-31