asp从excel读取数据的问题,求大神帮助
哪位大神帮我看看我的asp代码出了啥问题,从excel中读不了数据,excel中有字段客户名称;access中包含有客户名称字段,也有别的字段。部分代码如下:。。。。st...
哪位大神帮我看看我的asp代码出了啥问题,从excel中读不了数据,excel中有字段客户名称;access中包含有客户名称字段,也有别的字段。部分代码如下:
。。。。
strAddr = Server.MapPath(".")
datas=strAddr & "\Data\"&filename&".xls"
set conn=server.createobject("adodb.connection")
conn.open "driver={Microsoft Excel Driver (*.xls)};DBQ="&datas
Sql="Select * From [Sheet1$] "
set rsexcel=server.CreateObject("adodb.recordset")
rsexcel.open Sql,conn,1,1
if not (rsexcel.bof and rsexcel.eof) then
Set db = Server.CreateObject("ADODB.Connection")
db.Open "provider = microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\db1.mdb")
set rs = server.CreateObject("adodb.recordset")
sql="Select MAX(申请单号) as sqdmax From shenqingdan "
rs.open sql, db
sqdhmax = rs("sqdmax")
rs.close()
sql="Select * From shenqingdan "
rs.open sql,db,3,3
do
rs.addnew
sqdhmax = sqdhmax + 1
rs("申请单号") = sqdhmax
rs("申请人") = Session("username")
rs("客户名称")=rsexcel("客户名称")
rsexcel.movenext
loop while( not rsexcel.eof)
rs.update
rs.close
set rs=nothing
db.Close
Set db=Nothing
rsexcel.close
set rsexcel=nothing
conn.Close
Set conn=Nothing
response.write "<script>alert('\n\n批量提交成功!');location.href='index.asp';</script>"
end if
%>
</body>
</html> 展开
。。。。
strAddr = Server.MapPath(".")
datas=strAddr & "\Data\"&filename&".xls"
set conn=server.createobject("adodb.connection")
conn.open "driver={Microsoft Excel Driver (*.xls)};DBQ="&datas
Sql="Select * From [Sheet1$] "
set rsexcel=server.CreateObject("adodb.recordset")
rsexcel.open Sql,conn,1,1
if not (rsexcel.bof and rsexcel.eof) then
Set db = Server.CreateObject("ADODB.Connection")
db.Open "provider = microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\db1.mdb")
set rs = server.CreateObject("adodb.recordset")
sql="Select MAX(申请单号) as sqdmax From shenqingdan "
rs.open sql, db
sqdhmax = rs("sqdmax")
rs.close()
sql="Select * From shenqingdan "
rs.open sql,db,3,3
do
rs.addnew
sqdhmax = sqdhmax + 1
rs("申请单号") = sqdhmax
rs("申请人") = Session("username")
rs("客户名称")=rsexcel("客户名称")
rsexcel.movenext
loop while( not rsexcel.eof)
rs.update
rs.close
set rs=nothing
db.Close
Set db=Nothing
rsexcel.close
set rsexcel=nothing
conn.Close
Set conn=Nothing
response.write "<script>alert('\n\n批量提交成功!');location.href='index.asp';</script>"
end if
%>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询