Getting "Invalid bracketing of name" error when i try to run query on excel sheet

Milosh N picture Milosh N · Jul 24, 2009 · Viewed 9k times · Source

In order to make some reports I need to parse some excel files. When I try to select records from sheet I get next error: Invalid bracketing of name '1. page$'.

Heres my code:

OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [1. page$]", connectionString);

I know it will work if I rename sheet to "page" for example, but as i'm not naming these sheets I need to know how to fix this query to work as it is. What should I do?

Answer

Greg picture Greg · Jan 31, 2014

I had this same problem, replaced the . with a # and it works. Thanks!