Excel OleDbDataAdapter not reading the header row RRS feed

  • Question

  • Hello,


    I have an OleDbDataAdapter which connects to a worksheet's data in an excel workbook which then in turn fills a DataTable which then serves as a source for an unbound DataGridView.  In the process of testing, this has worked flawlessly.  However, today when using a new source workbook, the connection does not seem to be picking up the header row (in stepping through the code, the column names in the DataTable show up as F1, F2, etc) The new source workbook is identical to the previous workbook used (it's the same business objects report refreshed and saved to excel).  I've actually encountered a similar problem with linked excel tables in Access in the past, but just worked around it instead.  The same code will still work as intended, catching the header row and all, when reverting back to the original source workbook, so I'm just stumped as to what's different in the new source workbook that could be causing this. 


    Here's my connection string and the SQL statement for the adapter's select command:


    strXLSConn = "provider=Microsoft.Jet.OLEDB.4.0;data source=" + filePath+ ";Extended Properties='Excel 8.0;HDR=Yes'";

    xlsSQL = "select * from [" + xlsWSName + "$];";


    Any inside would be appreciated.  Thank you.

    Thursday, September 6, 2007 11:25 PM