title: OleDbCommand use brackets '[' ']' in a query as table name
body: <p>I have a <code>Excel</code> file which contains the following column names: <code>name</code>,<code>Display name [de-DE]</code>,<code>Comment [de-DE]</code>. </p>
  
  <p><a href="https://i.stack.imgur.com/HehlL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HehlL.png" alt="enter image description here"></a></p>
  
  <p>If I use this query, <code>Insert into [foo$] ([Name],[Display name [de-DE]],[Comment [de-DE]]</code>, I get an <code>exception:</code>.</p>
  
  <blockquote>
    <p>Syntax error in INSERT INTO statement</p>
  </blockquote>
  
  <p>How do I have to escape the <code>brackets</code> to use them in the query?</p>
  
  <h1>sample code</h1>
  
  <pre class="lang-cs prettyprint-override"><code>var connectionString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo.xlsx")}\";Extended Properties=\"Excel 12.0;HDR=YES;\"";
  
  using (OleDbConnection conn = new OleDbConnection(connectionString))
  {
      conn.Open();
      using (OleDbCommand cmd = new OleDbCommand())
      {
          try
          {
              cmd.Connection = conn;
              cmd.CommandText = @"Insert into [Hmi Tags$] ([Name],[Display name [de-DE]],[Comment [de-DE]]) 
                                  VALUES ('foo1','foo2','foo3');";
              cmd.ExecuteNonQuery();
              Console.WriteLine("success");
  
          }
          catch (Exception ex)
          {
              Console.WriteLine(ex.Message);
          }
      }
  }
  
  
  Console.ReadKey();
  </code></pre>
  
  <h1>workaround</h1>
  
  <p>The only working solution so far is based on this answer: <a href="https://stackoverflow.com/a/12499797/6229375">https://stackoverflow.com/a/12499797/6229375</a></p>
  
  <blockquote>
    <p>One option is to remove the column declaration completely and just do <code>insert into..</code></p>
  </blockquote>