0

我需要导入一个 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] 未找到数据源名称且未指定默认驱动程序。

是什么导致了这个错误?

4

1 回答 1

1

Instead of using the older ODBC drivers, try using the JET drivers (which I've done):

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

Or, if your data access drivers are up to date you can use the newer ACE OLEDB drivers (which I've moved to):

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

See connectionstrings.com for other ways to connect.

于 2013-10-18T13:55:07.087 回答