EXCEL表格导入问题
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e21'
多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。
/1.asp,行 33
<%dim action,excelpath,sheet,edate
action=trim(request.querystring("action"))
excelpath=trim(request.form("excelpath"))
sheet=trim(request.form("sheet"))
edate=trim(request.form("edate"))
select case action
case "daoru":call exctoacc(excelpath,sheet)
end select
function exctoacc(excpath,sheet)
Dim excConn,Coon
Dim excStrConn,strConn
Dim excrs,rs
Dim excSql
Set excconn=Server.CreateObject("ADODB.Connection")
Set excrs = Server.CreateObject("ADODB.Recordset")
excStrConn="Driver={Microsoft Excel Driver (*.xls)};DriverId=790; DBQ="&Server.MapPath(""&excpath&"")
excconn.Open excStrConn
excSql="select * from ["&sheet&"$]" '查询excel语句
excrs.Open excSql,excconn,2,2
set conn=server.createobject("adodb.connection")
conn.open"driver={microsoft access driver (*.mdb)};dbq="&server.mappath("mydata/yzsm!@#$%.asa")
set rs=server.createObject("ADODB.Recordset")
sql="select * from xueyuan" '查询Access表
rs.open sql,conn,1,3
do while Not excrs.EOF
rs.addnew
if edate="" then
for i=0 to excrs.Fields.Count-1
rs(i+1)=excrs(i)
next
else
for i=0 to excrs.Fields.Count-1
rs(i+1)=excrs(i) ‘此处为错误行
rs(1)=edate
next
end if
rs.update
excrs.MoveNext
Loop
rs.close
set rs=nothing
excrs.close
set excrs=nothing
excConn.close
set excConn=nothing
conn.close
set conn=nothing
response.write "<script language=javascript>"
response.write "alert('Excel表中的数据已经成功导入到数据库中!');"
response.write "location.href='1.asp';"
response.write "</script>"
End function
%>
<script language="JavaScript">
function check()
{
if (daoruf.excelpath.value=="")
{
alert("请输入Excel表的预处理数据路径!\n如果没有上传,请先上传Excel表再操作!");
daoruf.excelpath.focus();
return false;
}
if (daoruf.sheet.value=="")
{
alert("请输入数据表名!");
daoruf.sheet.focus();
return false;
}
return true;
}
</script>
<link href="../style.css" rel="stylesheet" type="text/css">
<form action="?action=daoru" method="post" name="daoruf" id="daoruf" onsubmit="return check();">
<div align="left">
<table width="600" border="1" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#D5EBF4">
<tr>
<td height="21" colspan="2" align="center">[<strong>从Excel表导入考生的录取信息</strong>]</td>
</tr>
<tr>
<td width="200">Excel表上传至服务器并预处理:</td>
<td width="400"><iframe width="450" height="60" src="/yzsmhotagali/tup_sh1.asp" frameborder="0" scrolling="no"></iframe>
<br>预处理数据路径:
<input name="excelpath" type="text" id="excelpath" size="30" readonly="true" /></td>
</tr>
<tr>
<td height="20" width="200">数据表名:</td>
<td><input name="sheet" type="text" id="sheet" value="sheet1"> 如:Sheet1