c# - Initial space in sheet name issue while importing sheet through OleDb objects -
i using olebb objects read excel file data table
system.data.oledb.oledbconnection mycon = new system.data.oledb.oledbconnection("provider=microsoft.ace.oledb.12.0;data source='" + filename + "';extended properties=\"excel 12.0;hdr=yes;imex=1\" "); system.data.oledb.oledbdataadapter cimport = new system.data.oledb.oledbdataadapter("select * [ gravity$a3:zz]", mycon ); cimport.fill(dt)
executing above query shows error :
invalid bracketing of name ' gravity$a3:zz'.
i think error due 1 space @ starting of sheet name " gravity".
if remove space in query & write "select * [gravity$a3:zz]", shows invalid object name.
how deal issue using oledb objects?
try putting name between quotes
system.data.oledb.oledbdataadapter cimport = new system.data.oledb.oledbdataadapter("select * [\" gravity$a3:zz\"]", mycon );
second: @panagiotiskanavos says
Α3:zz doesn't seem valid range
Comments
Post a Comment