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





Reply With Quote