【问题标题】:ADODB Connection Fails on Windows 7 but Not XPADODB 连接在 Windows 7 上失败,但不是 XP
【发布时间】:2015-11-28 04:53:40
【问题描述】:

我有一个简单的程序来测试使用 ADODB 打开与 excel 文件的连接。 这是使用 VBScript 的 ASP Classic。 代码如下:

<%@ Language="VBScript" %>
<% Response.buffer = true %>
<html>
<body>
<%

'Name of the excel file
exceldb="AW_Test.xls"
excel_file_name=Server.MapPath(exceldb)
response.write(excel_file_name)

Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790; DBQ=" &excel_file_name & ";"

cn.Close
Set cn=Nothing

Response.Write("All is good in the world...")

%>
</body>
</html>

尝试在此配置上运行时:

  • Windows 7 64 位
  • IIS 7
  • 32 位模式下的应用程序池
  • 根目录下的文件
  • 在本地主机上运行 [http://localhost/adotest.asp]

我得到以下结果:

C:\inetpub\wwwroot\AW_Test.xls 

Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data. 

/adotest2.asp, line 13 

但是,在同一台机器上,在此配置下:

  • XP 模式下的虚拟 PC
  • IIS 6
  • 根目录下的文件
  • 在本地主机上运行 [http://localhost/adotest.asp]

我得到以下结果:

c:\inetpub\wwwroot\AW_Test.xls
All is good in the world... 

我已经验证/尝试过的事情:

  • 已验证权限(注意这是根目录)
  • 尝试使用 Jet Engine 代替

       cn.Open 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\WWWRoot\AW_Test.xls;Extended Properties="Excel 8.0;HDR=No"'
    

出现错误:

C:\inetpub\wwwroot\AW_Test.xls
Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 

/adotest3.asp, line 13 
  • 已验证所有以 32 位模式运行的应用程序池
  • 数据源的 SYSWOW 端存在经过验证的驱动程序

我确信我错过了一些简单的东西,但是我已经没有东西可以尝试了。 我知道有比 ASP Classic 等更好的方法,但是,这应该仍然有效......

感谢您的帮助...

【问题讨论】:

标签: iis-7 asp-classic ado windows-7-x64


【解决方案1】:

尝试一下:

cn.Open "Driver={Microsoft Excel Driver (*.xls)}; DBQ=" &excel_file_name & ";"

它应该可以工作..

【讨论】:

    猜你喜欢
    • 2014-02-06
    • 2012-07-17
    • 2015-12-28
    • 1970-01-01
    • 2015-11-15
    • 2013-02-01
    • 2012-06-09
    • 1970-01-01
    • 2012-07-04
    相关资源
    最近更新 更多