title: How to Insert Rows to Table Object Inside an Excel Sheet?
body: <p>I have difficulties trying to insert rows into an existing table object. Here is my code snippet:</p>
  
  <pre><code>string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + @"C:\myExcelFile.xlsx" + ";Extended Properties=\"Excel 12.0;ReadOnly=False;HDR=Yes;\"";
  using (OleDbConnection conn = new OleDbConnection(connectionString))
  {
      conn.Open();
      OleDbCommand cmd = new OleDbCommand();
      cmd.Connection = conn;
  
      string insertQuery = String.Format("Insert into [{0}$] (ID, Title,NTV_DB, Type ) values(7959, 8,'e','Type1')", TabDisplayName);
      cmd.CommandText = insertQuery;
      cmd.ExecuteNonQuery();
      cmd = null;
      conn.Close();
  }
  </code></pre>
  
  <p>As a result I get my rows inserted below a ready-made table object:</p>
  
  <p><img src="https://i.stack.imgur.com/U7SGh.png" alt="enter image description here"></p>
  
  <p>I've also tried inserting data inside a table object like so:</p>
  
  <pre><code> string insertQuery = String.Format("Insert into [{0}$].[MyTable] (ID, Title,NTV_DB, Type ) values(7959, 8,'e','Type1')", TabDisplayName);
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>The Microsoft Access database engine could not find the object 'MyTable'. Make sure the object exists and that you spell its name and the path name correctly. If 'MyTable' is not a local object, check your network connection or contact the server administrator.</p>
  </blockquote>
  
  <p>As you can see, table with a name <code>MyTable</code> does exist. I would be very grateful if someone can shed some light on this mystery.</p>
  
  <p><img src="https://i.stack.imgur.com/zv9NJ.png" alt="enter image description here"> </p>