Select specific rows within Excel

I have the following select

MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)

How would I configure the select statement to start on a specific row (say row 14) and go until the there were no more rows with data?

JedidiaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne Taylor (webtubbs)Commented:
You can do that like this....

    MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$14:65536]", MyConnection)

Wayne
0
JedidiaAuthor Commented:
Hi Webtubbs - This works great for starting at row 14, but is there also a way to identify the last row with data and the select stops at that row?

I am passing this to a datatable and it adds ALOT of empty rows in my datatable..:)
0
Wayne Taylor (webtubbs)Commented:
You can inform the DataAdapter to not include blank rows by using a WHERE clause....

    MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$14:65536] WHERE F1 <> ''", MyConnection)

...where F1 is the first column. The second column would be F2, the third F3, etc.

Wayne
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.