ADODB连接在Windows 7但不是XP上失败

时间:2013-06-26 18:14:21

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

我有一个简单的程序来测试使用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模式下的Virtual PC
  • IIS 6
  • 根目录中的文件
  • 在本地主机上运行[http://localhost/adotest.asp]

我得到以下结果:

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

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

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

       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等更好的方法,但是,这应该仍然有用......

我感谢任何帮助...

1 个答案:

答案 0 :(得分:0)

尝试使用:

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

它应该有用..

相关问题