I am using OleBb objects to read excel file into 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 * from [ Gravity$A3:ZZ]", myCon );
cImport.Fill(dt)
Executing above query shows Error :
Invalid bracketing of name ' Gravity$A3:ZZ'.
I think this error is due to one space at starting of sheet name " Gravity".
If I remove this space in query & write like "select * from [Gravity$A3:ZZ]", then it shows invalid object name.
How to deal with this issue only using OleDb objects?
try putting the name between quotes
Second: as @PanagiotisKanavos says