I want to be able to read from and write to an excel file using Classic ASP stored in my local machine at
C:\Inetpub\wwwroot\excel\excel.xls
I tried using the following code:
<%
' 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
%>
Which I got from here
But I got the following error:
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
I'm just a beginner with ASP and not sure what to do. Please help out!
Is your server a 64 bit machine. If it is you may need to enable 32 bit applications in your application pool
You could try one of the connection strings here. http://www.connectionstrings.com/microsoft-jet-ole-db-4-0/
If you have a copy of MS Access I recommend that you import your excel spreadsheet into an Access database and connect to that. Using excel directly as a datasource can be painful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.