[英]Reading and Writing Data Excel File Classic ASP
我希望能夠使用存儲在本地計算機中的 Classic ASP 讀取和寫入 excel 文件
C:\Inetpub\wwwroot\excel\excel.xls
我嘗試使用以下代碼:
<%
' 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
%>
我從這里得到的
但我收到以下錯誤:
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 的初學者,不知道該怎么做。 請幫忙!
你的服務器是 64 位機器嗎? 如果是,您可能需要在應用程序池中啟用 32 位應用程序
您可以嘗試此處的連接字符串之一。 http://www.connectionstrings.com/microsoft-jet-ole-db-4-0/
如果您有 MS Access 的副本,我建議您將 Excel 電子表格導入 Access 數據庫並連接到該數據庫。 直接使用 excel 作為數據源可能會很痛苦。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.