Excel VBA - ADO RecordSet returning row 2 as header row instead of row 1?

Up vote 0 down vote favorite share g+ share fb share tw.

I am opening a connection to an Excel 2003 (.xls) worksheet using the following code: Set adoConn = New ADODB. Connection Set adoRS = New ADODB. Recordset With adoConn .

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & vendorSource & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";" . Open End With adoRS. CursorLocation = adUseClient adoRS.

CursorType = adOpenStatic adoRS. ActiveConnection = adoConn adoRS. Open "SELECT * FROM 6000_600_VENDOR_MAIN_INFO" This has properly returned results from the worksheet up until recently.

In the current spreadsheet that I am connecting to, the recordset is returning row 2 as the header row instead of row 1. I am not sure what has changed in the spreadsheet. Visually looking at the spreadsheet, it appears nothing is different except the cell formatting for the header row.

I tried clearing the formats for row 1, but it didn't make any difference. What could be causing the recordset to return row 2 as the header row instead of row 1? Something else to note is that I am making the connection from Excel 2007, but connecting to an Excel 2003 formatted spreadsheet.

TIA for any suggestions. Excel-vba ado recordset link|improve this question asked Mar 29 at 17:21Ashaelon11.

– Francis P Mar 29 at 18:47 There are 1202 rows on the worksheet. Row 1 is the column headers; row 2 starts the data. The recordset is ignoring row 1 as far as I can tell and returning row 2 as the header row (recordset field names), then it returns all of the data starting from row 3.

It should be returning row 1 as the header row and row 2 as the start of data. – Ashaelon Mar 29 at 21:22 As for your question, if you are asking if the query is returning both row 1 and row 2 as the header row, how could I tell? Referring to the header name (from row 1 of the worksheet) as a field name causes an error saying the field is not found.

– Ashaelon Mar 29 at 21:31 Is 6000_600_VENDOR_MAIN_INFO a named range or the name of the worksheet? If it's a named range, does it still include the headings? – creamyegg Mar 30 at 8:17 @creamyegg: 6000_600_VENDOR_MAIN_INFO is the name of the database.

@Ashaelon: Have you verified in debug mode what was returned by your query, add a spy on your recordset? – Francis P Mar 30 at 12:43.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions