title: Exception while inserting C# datatable into Access table - System.InvalidOperationException: Missing the DataColumn 'ID' for the SourceColumn 'ID'
body: <p>I am getting the aforementioned exception when I am trying to insert all the rows from my table that has a primary key value on a string column "MedName", into an Access table that has an auto-incremented primary key. This is what I am doing: </p>
  
  <pre><code>OleDbConnection con;
  OleDbCommand cmd;
  OleDbDataAdapter adapter;
  string Connection ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Directory;
  con=new OleDbConnection(Connection);
  string selectCommand = "select * from AccessTableTest";
  cmd=new System.Data.OleDb.OleDbCommand(Query,con) ;
  adapter=new OleDbDataAdapter(cmd);
  OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
  dt.PrimaryKey = null; //Tried to see if PK is causing trouble. No luck
  foreach (DataRow dr in dt.Rows)
  {
      dr.SetModified(); //Tried this. Helped me to insert for the very first time.
  }
  adapter.InsertCommand = builder.GetInsertCommand();
  var rows = adapter.Update(dt); //dt is the function parameter
  con.Close();
  </code></pre>
  
  <p>SO, adapter.Update(dt) throws error "Missing the DataColumn 'ID' for the SourceColumn 'ID'"</p>
  
  <p>Note: The very first insert command was successful with dr.SetModified() statement but all the subsequent inserts fail. I made sure that all columns of table match with those of access table.</p>
  
  <p>Also, the insert command from adapter.InsertCommand looks like this:</p>
  
  <pre><code>INSERT INTO DrugAudit (Category, SubCategory, Quantity, MedName, OrderTrigger, Issues, Price, Notes, Summary, Recommendations, Alternative) 
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  </code></pre>
  
  <p>Please help. I have been trying to resolve this for couple of days now. Thanks!</p>