0

I have searched a lot but didn't find a question like what I have.

I am opening an excel sheet with an OleDB connection and want to select (unnamed) columns, but not an entire range. The columns I want to select are:

B, F, M, O-X

I have tried a lot of ways to format the select and the closest I come to a result that actually passes through is this:

"SELECT TOP " + this.maximumRows.ToString() + " * FROM [Sheet1$B:B], [Sheet1$F:F], [Sheet1$M:M], [Sheet1$O:X]"

However what i get out of that is this (commas separate cells):

Data , [Sheet1$F:F] , [Sheet1$M:M] , [Sheet1$O:X] , F2 , F3 , etc...

Can anyone tell me how to form the SELECT statement so it takes the actual data instead of the rest of the query?

1 Answer 1

1

I would rather try something like SELECT TOP X F2, F6 from [Sheet1] ?

Sign up to request clarification or add additional context in comments.

5 Comments

Sadly that give me an error. i tried [B], B, Sheet1.B, [Sheet1].B, [Sheet1.B] and Sheet1.[B] but i keep getting the following error "No value given for one or more required parameters."
Did you try with [F1], [F2] ... ? This is how Excel columns are shown in Access when no field names are provided.
Sadly [F1] or F1 doesnt work either, still giving the same error. This it the base of my query: "SELECT F1 (or [F1] doesnt work either) FROM [Sheet1$]"
Strange ! See stackoverflow.com/questions/3201231/… and... what if you remove the TOP clause ?
using SELECT 1 As Col, F2 As Cont ... just printed the strings Col and Cont. I used the TOP in previous tries where the DataAdapter did not stop retrieving rows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.