title: DataGridView to MS Access Database
body: <p>I'm trying to update a database after the changes in a DataGridView.</p>
  
  <p>After changing the code several times, I've come to this one-liner:</p>
  
  <pre><code>primeTableAdapter.Update((PrimeDataSet.PrimeDataTable)(primeDataSet.Tables["Prime"]));
  </code></pre>
  
  <p>The method returns the correct number of rows added / edited and entering the form again without closing the entire application everything seems fine. The new rows are kept in the DataGridView. However, the Access file is not changed one bit, so when I relaunch the application they disappear.</p>
  
  <p>I've bound the DataGridView to the table using the "Add New Data Source" wizard and I'm using Visual Studio 2010.</p>
  
  <p>I've also found the code at: <a href="https://stackoverflow.com/questions/9784301/inserting-data-from-a-datagridview-to-a-database">Inserting data from a DataGridView to a database</a> and it seems similar to what I have to do, but I wasn't able to translate the vb.net code to something that would compile. However, I'm fairly sure it is really, really close to what I have to do.</p>
  
  <p><b>Later Edit: I had added the database to the project. By setting the Copy to Output Directory property to Copy if Newer the changes were persistent between sessions.</b></p>