0

I am developing a C# windows form application. This simple application is basically a form where the user can save, edit and delete some data in a MS Access database. When I debug the code, it works properly (I save the data end it appears as a new line in datagridview). The problem is that when I close the form and open it again, the datagridview do not show the record I just saved, and the new record is not saved in MS Access database. Here is the code I using to save the record:

private void btnSalvar_Click(object sender, EventArgs e)
    {
        try
        {                
            materiaisBindingSource.EndEdit();
            materiaisTableAdapter.Update(this.appData.Materiais);
            this.appData.Materiais.AcceptChanges();                                                   
            groupBox1.Enabled = false;
         }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Error);
            materiaisBindingSource.ResetBindings(false);
        }
    }

Please, can someone help me?

YowE3K
  • 23,852
  • 7
  • 26
  • 40
  • 1
    Your'e just updating a local data source, you never update the database. – Koby Douek May 14 '17 at 13:44
  • Probably a case of [Why saving changes to a database fails](http://stackoverflow.com/questions/17147249/why-saving-changes-to-a-database-fails/17147460#17147460) Please check – Steve May 14 '17 at 13:44
  • Thank you a lot @Steve ! I just changed the property Copy to output directory to **copy if newer**. – Tulio Ferreira May 14 '17 at 18:49

0 Answers0