i am reading an excel file using this code i found over the net:
<% Option Explicit %>
<html>
<body>
<%
Dim objConn, objRS, strSQL
Dim x, curValue
Dim valuesArray()
strSQL = "SELECT * FROM A1:A200"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO; "&_
"Excel 8.0; DBQ=" & Server.MapPath("myExcel.xls") & "; "
Set objRS=objConn.Execute(strSQL)
Response.Write("<table border=""1"">")
Response.Write("<tr>")
For x=0 To objRS.Fields.Count-1
Response.Write("<th>" & objRS.Fields(x).Name & "</th>")
Next
Response.Write("</tr>")
Do Until objRS.EOF
Response.Write("<tr>")
For x=0 To objRS.Fields.Count-1
curValue = objRS.Fields(x).Value
If IsNull(curValue) Then
curValue="N/A"
End If
curValue = CStr(curValue)
valuesArray(x) = curValue
Response.Write("<td>" & valuesArray(x) & "</td>")
Next
Response.Write("</tr>")
objRS.MoveNext
Loop
objRS.Close
Response.Write("</table>")
objConn.Close
Set objRS=Nothing
Set objConn=Nothing
%>
</body>
</html>
upon first visit of the page the excel file is read properly. but if i refresh the page i get this error:
Provider error ‘80004005’
Unspecified error
would you happen to know what is causing this and how can i fix it?
Most of the time this error is because you are refreshing too fast; if you were to wait like 10 sec or so it should not give you that error. Though ASP/ADO applications support multi-user access, an Excel spreadsheet does not. Therefore, this method of querying and updating information does not support multi-user concurrent access.
see http://support.microsoft.com/kb/q195951/