vb.net - OleDB Get Table Issue - Sheet Name is Completely Numerical -
i'm using following function sheet name oledb schema table:
public function getsheetname(byval dtschema datatable) string dim sheetname string = "" try if not dtschema.rows(0)("table_name").tostring().contains("#") sheetname = dtschema.rows(0)("table_name").tostring() end if catch ex exception buildresulttracestring("exception in getsheetname") buildresulttracestring(ex.message) end try return sheetname end function and table so:
sql.append("select * [" & sheetname & "a22:t10000]") dt = _dh.gettable(sql.tostring()) however, when try load sheet named '20130418113010937', table method catches exception:
the microsoft access database engine not find object ''20130418113010937$'a2:i10000'
it works other sheet names i'm using, won't work one. assume it's because it's numerical. there workaround this? process automated, cannot manually change sheet name unless somehow programmatically.
thanks!
you're right, problem numeric sheet name. when retrieve sheet name using oledb 'favor' surrounding numeric names single quotes (presumably retain stringyness).
remove single quotes both ends of table name , should good:
sheetname = dtschema.rows(0)("table_name").tostring().trim("'")
Comments
Post a Comment