ASP页面中调用EXCEL数据,出现溢出错误
MicrosoftOLEDBProviderforODBCDrivers错误'80004005'[Microsoft][ODBCExcelDriver]数值字段溢出。<%...
Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005'
[Microsoft][ODBC Excel Driver] 数值字段溢出。
<%
Dim conn
Dim StrConn
Dim rs
Dim Sql
Set conn=Server.CreateObject("ADODB.Connection")
StrConn="Driver={Microsoft Excel Driver (*.xls)};DBQ="& Server.MapPath("Book1.xls")
conn.Open StrConn
Set rs = Server.CreateObject("ADODB.Recordset")
Sql="select * from [Sheet1$] order by 序号 asc"
rs.Open Sql,conn,1,1
%>
<center>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<%
for i=0 to rs.Fields.Count-1
%>
<td width="1" bgcolor="#CCCCCC"></td>
<td height="28" bgcolor="#ece9d8"><div align="center"><%=rs(i).Name%></div></td>
<%
next
%>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
<%
do while Not rs.EOF
%>
<tr>
<%
for i=0 to rs.Fields.Count-1
%>
<td width="1" bgcolor="#CCCCCC"></td>
<td height="28" valign="bottom"><%=rs(i)%></td>
<%
next
%>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
<tr>
<% '生成高度为1的空行(横线)
for i=0 to rs.Fields.Count-1
%>
<td height="1" bgcolor="#CCCCCC"></td>
<td height="1" bgcolor="#CCCCCC"></td>
<%
next
%>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
<%
rs.MoveNext 〈----------------------------------------- 错误处!
Loop
rs.close
set rs=nothing
Conn.close
set StrConn=nothing
%>
</table>
我从网上查到的资料,但我不会用,只会用现成的代码,谢谢!
1、conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Extended properties=Excel 5.0;Data Source=c:\book1.xls" (使用jet 引擎)
2、Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Text Driver (*.txt; *.csv)};"
DBPath = "DBQ=" & Server.MapPath( "Text" ) (把EXCEL转换为文本.csv格式)
3、"driver={microsoft excel driver (*.xls)};"&filepath (这种方法容易导致错误:[Microsoft][ODBC excel driver] 数值字段溢出) 展开
[Microsoft][ODBC Excel Driver] 数值字段溢出。
<%
Dim conn
Dim StrConn
Dim rs
Dim Sql
Set conn=Server.CreateObject("ADODB.Connection")
StrConn="Driver={Microsoft Excel Driver (*.xls)};DBQ="& Server.MapPath("Book1.xls")
conn.Open StrConn
Set rs = Server.CreateObject("ADODB.Recordset")
Sql="select * from [Sheet1$] order by 序号 asc"
rs.Open Sql,conn,1,1
%>
<center>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<%
for i=0 to rs.Fields.Count-1
%>
<td width="1" bgcolor="#CCCCCC"></td>
<td height="28" bgcolor="#ece9d8"><div align="center"><%=rs(i).Name%></div></td>
<%
next
%>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
<%
do while Not rs.EOF
%>
<tr>
<%
for i=0 to rs.Fields.Count-1
%>
<td width="1" bgcolor="#CCCCCC"></td>
<td height="28" valign="bottom"><%=rs(i)%></td>
<%
next
%>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
<tr>
<% '生成高度为1的空行(横线)
for i=0 to rs.Fields.Count-1
%>
<td height="1" bgcolor="#CCCCCC"></td>
<td height="1" bgcolor="#CCCCCC"></td>
<%
next
%>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
<%
rs.MoveNext 〈----------------------------------------- 错误处!
Loop
rs.close
set rs=nothing
Conn.close
set StrConn=nothing
%>
</table>
我从网上查到的资料,但我不会用,只会用现成的代码,谢谢!
1、conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Extended properties=Excel 5.0;Data Source=c:\book1.xls" (使用jet 引擎)
2、Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Text Driver (*.txt; *.csv)};"
DBPath = "DBQ=" & Server.MapPath( "Text" ) (把EXCEL转换为文本.csv格式)
3、"driver={microsoft excel driver (*.xls)};"&filepath (这种方法容易导致错误:[Microsoft][ODBC excel driver] 数值字段溢出) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询