Click to See Complete Forum and Search --> : ODBC Connection Error 80004005
cassandra
Dec 7th, 2000, 12:33 AM
Hello,
I need to create an online monitoring system. Currently i have already create an application using VB that interface with the hardware and read in data and store it into excel file. I have also create an asp that extract data from the excel file and display on the webpage. But i encountered error
Provider error '80004005'
Unspecified error
/fyp.asp, line 26
Line 26 : cnnExcel.Open "DBQ=" & Server.MapPath("temp.xls") & ";" & _"DRIVER={Microsoft Excel Driver (*.xls)};"
Pls help..
monte96
Dec 7th, 2000, 09:25 AM
You'll need to post more code than just the line that errored... it is entirely likely that that line is not the cause of the error.. it is just where the error occurs.
cassandra
Dec 7th, 2000, 07:55 PM
<%
'*******************************************************
'* ASP 101 Sample Code - http://www.asp101.com *
'* *
'* This code is made available as a service to our *
'* visitors and is provided strictly for the *
'* purpose of illustration. *
'* *
'* Please direct all inquiries to webmaster@asp101.com *
'*******************************************************
%>
<%
' Selected constants from adovbs.inc
Const adOpenStatic = 3
Const adLockPessimistic = 2
Dim cnnExcel
Dim rstExcel
Dim I
Dim iCols
' This is all standard ADO except for the connection string.
' You can also use a DSN instead, but so it'll run out of the
' box on your machine I'm using the string instead.
Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath("temp.xls") & ";" & _
"DRIVER={Microsoft Excel Driver (*.xls)};"
' Same as any other data source.
' FYI: TestData is my named range in the Excel file
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstExcel.Open "SELECT * FROM TestData;", cnnExcel, _
adOpenStatic, adLockPessimistic
' Get a count of the fields and subtract one since we start
' counting from 0.
iCols = rstExcel.Fields.Count
%>
<html>
<head>
<title></title>
</head>
<body background="/images/bground.gif" bgcolor="#ffffff" text="#000000" marginheight="0" topmargin="0">
<table border="1">
<thead>
<%
' Show the names that are contained in the first row
' of the named range. Make sure you include them in
' your range when you create it.
For I = 0 To iCols - 1
Response.Write "<th>"
Response.Write rstExcel.Fields.Item(I).Name
Response.Write "</th>" & vbCrLf
Next 'I
%>
</thead>
<%
rstExcel.MoveFirst
' Loop through the data rows showing data in an HTML table.
Do While Not rstExcel.EOF
Response.Write "<tr>" & vbCrLf
For I = 0 To iCols - 1
Response.Write "<td>"
Response.Write rstExcel.Fields.Item(I).Value
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write "</tr>" & vbCrLf
rstExcel.MoveNext
Loop
%>
</table>
<%
rstExcel.Close
Set rstExcel = Nothing
cnnExcel.Close
Set cnnExcel = Nothing
%>
</body>
</html>
Pls advice..
monte96
Dec 8th, 2000, 08:43 AM
Your code, unmodified, works on my system with an Excel file I created to match your names.
Perhaps there is something screwy in your data? Something that is not displayable using ADO. I've never used ADO to access an Excel file before. I would rather create an instance of Excel on the server and convert it to whatever format I need but the code does work, although it doesn't handle blank cells very well.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.