Results 1 to 4 of 4

Thread: ODBC Connection Error 80004005

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    36

    Unhappy

    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..

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    36
    Code:
    <%
    '*******************************************************
    '*     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 [email protected] *
    '*******************************************************
    %>
    <%
    ' 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..

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width