【问题标题】:Issue while importing Excel ( classic ASP )导入 Excel 时出现问题(经典 ASP)
【发布时间】:2013-10-18 05:57:45
【问题描述】:

我需要导入一个 Excel 文件。我正在使用以下代码连接到工作表:

Set objConn = Server.CreateObject ("ADODB.Connection")

objConn.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=" & Server.mappath(C:\sample\abcd.xls) & ";ReadOnly= false ; UID=admin;"

这样做时,我收到以下错误:

用于 ODBC 驱动程序的 Microsoft OLE DB 提供程序错误“80004005”。

[Microsoft][ODBC Driver Manager] 数据源名称未找到且无 指定默认驱动程序。

是什么导致了这个错误?

【问题讨论】:

  • Server.mappath("C:\sample\abcd.xls") 引用?

标签: excel asp-classic


【解决方案1】:

不要使用旧的 ODBC 驱动程序,而是尝试使用 JET 驱动程序(我已经这样做了):

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(C:\sample\abcd.xls) & ";
Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"

或者,如果您的数据访问驱动程序是最新的,您可以使用较新的 ACE OLEDB 驱动程序(我已移至该驱动程序):

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath(C:\sample\abcd.xls) & ";
Extended Properties=""Excel 12.0;HDR=YES"";"

请参阅connectionstrings.com 了解其他连接方式。

【讨论】: