vb.net - Using a excel range in an oledb select statement -



vb.net - Using a excel range in an oledb select statement -

in vb.net, i'm reading 1 column of larger excel spreadsheet datagrid using oledb. normal select statement reading entire sheet this:

da2 = new oledbdataadapter("select * [sheet3$]", cn)

for reading single column larger sheet, works:

da2 = new oledbdataadapter("select * [sheet3$a:a" & lastrow & "]", cn) 'this reads entire column downwards integer value in variable 'lastrow'

my goal, now, read entire sheet loop, column column, turning sheet reference string or vb.net concatenate/cast string , range (which won't). i've tried these options, far without success:

for colindex = 2 lastcol3 colrange = xlwsheet3.range(xlwsheet3.cells(toprow, colindex), xlwsheet3.cells(lastrow3.colindex) addy = colrange.address da2 = new oledbdataadapter("select * [sheet3$" & addy & "]", cn)

no matter try, comes downwards fact oledb adapter won't reconcile string excel.range. there easier way read single column excel looping? i'm new programming, advice helpful.

i've ditched oledb column-by-column loop, , instead have gone straight excel.interop loop, via post:

filling datagrid columns w/ excel info in vb

i don't think oledb meant detailed/complicated reading...

vb.net excel datagridview oledb

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -