asp网页中EXCEL 表格导入SQL2000数据库问题
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><!--#includefile="c...
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!--#include file="conn.asp"-->
<!--#include FILE="clsUp.asp"-->
<%
dim excel,conn,rs_sql,msglist,rs_xls, str_xls,conn_xls
'On Error Resume Next
set conn=Server.CreateObject("ADODB.Connection")
Call Open_Conn("keyan","87150201","sa","(local)",SqlConn)
msglist="select * from keyan"
rs_sql.open Conn ,msglist,1,3
function open_excel_conn(filename)
Set excel_conn=server.createobject("adodb.connection")
excel="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.Mappath(filename)&";Extended Properties='Excel 8.0';"
excel_conn.open excel
If Err.Number <> 0 Then
Response.write "不能打开指定的Excel,请查实!<a href='upexcel.htm'>返回</a>"
Response.end
else
set conn_xls=server.createobject("adodb.connection")
conn_xls.open excel
set rs_xls=server.createobject("adodb.recordset")
str_xls="select * from [Sheet1$]"
rs_xls.open conn_xls,str_xls,1,1
rs_sql.AddNew
rs_sql("classid")=rs_xls(i,1)
rs_sql("jsrq")=rs_xls(i,2)
rs_sql("jdr")=rs_xls(i,3)
rs_sql("sqr")=rs_xls(i,4)
rs_sql("leibie")=rs_xls(i,5)
rs_sql("wldm")=rs_xls(i,6)
rs_sql("item")=rs_xls(i,7)
rs_sql("title")=rs_xls(i,8)
rs_sql("num")=rs_xls(i,9)
rs_sql("yqjq")=rs_xls(i,10)
rs_sql("fxrq")=rs_xls(i,11)
rs_sql("rwdh")=rs_xls(i,12)
rs_sql("enddate")=rs_xls(i,13)
rs_sql("ztsm")=rs_xls(i,14)
rs_sql("content")=rs_xls(i,15)
rs_sql("postdate")=rs_xls(i,16)
rs_sql("stats")=rs_xls(i,17)
rs_sql("lscs")=rs_xls(i,18)
rs_sql("cqcs")=rs_xls(i,19)
rs_sql("lsdate")=rs_xls(i,20)
rs_sql("cqdate")=rs_xlss(i,21)
rs_sql("yuanyin")=rs_xls(i,22)
rs_sql("yuanyin")=rs_xls(i,23)
rs_sql("yyfx")=rs_xls(i,24)
rs_sql("tzzt")=rs_xls(i,25)
rs_sql("qtjswt")=rs_xls(i,26)
rs_sql("bomzt")=rs_xls(i,27)
rs_sql("gywjzt")=rs_xls(i,28)
rs_sql("wlzt")=rs_xls(i,29)
rs_sql("csjxqk")=rs_xls(i,30)
rs_sql.Update
end if
Rs.MoveNext
Loop
end if
%> 展开
<!--#include file="conn.asp"-->
<!--#include FILE="clsUp.asp"-->
<%
dim excel,conn,rs_sql,msglist,rs_xls, str_xls,conn_xls
'On Error Resume Next
set conn=Server.CreateObject("ADODB.Connection")
Call Open_Conn("keyan","87150201","sa","(local)",SqlConn)
msglist="select * from keyan"
rs_sql.open Conn ,msglist,1,3
function open_excel_conn(filename)
Set excel_conn=server.createobject("adodb.connection")
excel="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.Mappath(filename)&";Extended Properties='Excel 8.0';"
excel_conn.open excel
If Err.Number <> 0 Then
Response.write "不能打开指定的Excel,请查实!<a href='upexcel.htm'>返回</a>"
Response.end
else
set conn_xls=server.createobject("adodb.connection")
conn_xls.open excel
set rs_xls=server.createobject("adodb.recordset")
str_xls="select * from [Sheet1$]"
rs_xls.open conn_xls,str_xls,1,1
rs_sql.AddNew
rs_sql("classid")=rs_xls(i,1)
rs_sql("jsrq")=rs_xls(i,2)
rs_sql("jdr")=rs_xls(i,3)
rs_sql("sqr")=rs_xls(i,4)
rs_sql("leibie")=rs_xls(i,5)
rs_sql("wldm")=rs_xls(i,6)
rs_sql("item")=rs_xls(i,7)
rs_sql("title")=rs_xls(i,8)
rs_sql("num")=rs_xls(i,9)
rs_sql("yqjq")=rs_xls(i,10)
rs_sql("fxrq")=rs_xls(i,11)
rs_sql("rwdh")=rs_xls(i,12)
rs_sql("enddate")=rs_xls(i,13)
rs_sql("ztsm")=rs_xls(i,14)
rs_sql("content")=rs_xls(i,15)
rs_sql("postdate")=rs_xls(i,16)
rs_sql("stats")=rs_xls(i,17)
rs_sql("lscs")=rs_xls(i,18)
rs_sql("cqcs")=rs_xls(i,19)
rs_sql("lsdate")=rs_xls(i,20)
rs_sql("cqdate")=rs_xlss(i,21)
rs_sql("yuanyin")=rs_xls(i,22)
rs_sql("yuanyin")=rs_xls(i,23)
rs_sql("yyfx")=rs_xls(i,24)
rs_sql("tzzt")=rs_xls(i,25)
rs_sql("qtjswt")=rs_xls(i,26)
rs_sql("bomzt")=rs_xls(i,27)
rs_sql("gywjzt")=rs_xls(i,28)
rs_sql("wlzt")=rs_xls(i,29)
rs_sql("csjxqk")=rs_xls(i,30)
rs_sql.Update
end if
Rs.MoveNext
Loop
end if
%> 展开
展开全部
用ASP导入到数据库里是非常简单的事。不过在XP下,就不能成功。总是报错。不是你的代码写错了。而是其他原因,例如驱动或者缺少什么组建。你可以在win2000/2003下测试。应该可以成功。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询