2014-03-13 424 views
0

我希望能够在读取和写入数据的Excel文件经典ASP

C:\Inetpub\wwwroot\excel\excel.xls 

我用下面的代码试图读取和写入使用经典ASP存储在我的本地机器上的Excel文件:

<% 
' Set Connection Params 
Set oConn = Server.CreateObject("ADODB.connection") 
oConn.Open "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;" &_ 
"DBQ=c:\Inetpub\wwwroot\excel\excel.xls;" &_ 
"DefaultDir = C:\Inetpub\wwwroot\excel\" 

Set RS=Server.CreateObject("ADODB.recordset") 

' Write the SQL Query 
RS.open "SELECT * FROM my_range", oConn 

do until RS.EOF 
Response.Write (RS("NAME") & " -- " & RS("EMAIL") & "") 
RS.movenext 
Loop 

'Close the recordset/connection 

RS.Close 
oConn.Close 
Set RS = Nothing 
%> 

这是我从here

了,但我得到了以下错误:

Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

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

/ASP/excel.asp, line 4 

我只是一个ASP初学者,不知道该怎么做。请帮帮忙!

回答

0
  1. 您的服务器是64位机器。如果是,您可能需要确保您的应用程序池,32个应用程序

  2. 你可以尝试连接字符串中的一个位置。 http://www.connectionstrings.com/microsoft-jet-ole-db-4-0/

如果你的MS Access的副本,我建议您导入Excel电子表格导入Access数据库,并连接到。直接使用Excel作为数据源可能会很痛苦。