Results 1 to 3 of 3

Thread: Please Help Me...

  1. #1

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645

    Please Help Me...

    Can anyone see a problem with this???

    I use this method all the time to connect to an Excel Datasource using ADO but for some reason it keeps missing some of the data its the cells for this particular spreadsheet.

    I've attached a couple of screen prints, the first shows a screen print of the excel data and the second shows the result of using this code.

    Its really annoying me.

    Any help on the problem, or even a workaround, would be appreciated.

    Code:
    <%
    Dim cnnExcel, rstExcel, conn
    
    conn = "SELECT * FROM [Sheet1$];"
    
    Set cnnExcel = Server.CreateObject("ADODB.Connection")
    cnnExcel.Open "DBQ=" & Server.MapPath("Data.xls") & ";" & "DRIVER={Microsoft Excel Driver (*.xls)};uid=Admin;"
    
    Set rstExcel = Server.CreateObject("ADODB.Recordset")
    rstExcel.Open conn, cnnExcel
    
    iCols = rstExcel.Fields.Count
    %>
    <div style="text-align:center; width:100%;">
    <table border="1" width="50%">
    	<thead>
    		<%
    		For i = 0 To iCols - 1
    			Response.Write "<th>"
    			Response.Write rstExcel.Fields.Item(i).Name
    			Response.Write "</th>" & vbCrLf
    		Next
    		%>
    	</thead>
    	<%
    	rstExcel.MoveFirst
    	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>
    </div>
    
    <%
    rstExcel.Close
    cnnExcel.Close
    Set rstExcel = Nothing
    Set cnnExcel = Nothing
    %>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  2. #2

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    sorry, it removed my attachment
    Attached Files Attached Files
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3

    Thread Starter
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Its strange because if a pick a cell item using...

    Code:
    conn = "SELECT * FROM [Sheet1$:A1:A5];"
    ... it picks it up fine???
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

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