2013-06-26 65 views
2

我有一个简单的程序来测试使用ADODB打开连接到excel文件。 这是使用VBScript的ASP Classic。 下面是代码:在Windows 7上ADODB连接失败,但不是XP

<%@ 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> 

当试图在这个配置下运行:

  • 64位Windows 7
  • 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尝试引擎改为

    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经典等更好的方法,但是,这应该仍然工作......

我感谢所有帮助...

+0

请检查接受的答案在这:http://forums.iis.net/t/1174099.aspx。 – SearchAndResQ

回答

0

尝试用刚:

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

它应该工作..

+0

完全相同的错误... –

相关问题