user2132375
user2132375

Reputation: 11

Visual C# And Microsoft Access 2007

See this image

The DataGridView is updating but Contacts.accdb is not changing.

I want it to change it, Can you help?

Solved :

private void Form1_Load(object sender, EventArgs e)
{
    this.contactsTableAdapter.Fill(this.contactsDataSet.Contacts);
    dataGridView1.DataSource = contactsDataSet.Contacts;
    try
    {
        DataRow row = contactsDataSet.Contacts.NewRow();
        row[0] = contactsDataSet.Contacts.Rows.Count + 1;
        row[1] = "Dsatasdasfo";
        row[2] = "Maisgfdgdfuradze";
        row[3] = 596110800;
        row[4] = "Tserefgdfgdteli Ave, Building 10";
        contactsDataSet.Contacts.Rows.Add(row);
    }
    catch (ConstraintException error)
    {
        MessageBox.Show(error.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
    }
    finally
    {
        contactsTableAdapter.Adapter.Update(contactsDataSet.Contacts);
    }
}

Upvotes: 0

Views: 70

Answers (1)

Simon
Simon

Reputation: 6152

You don't persist the changes back to the database in your code, you need to call:

ContactsDataAdapter.Update()

Upvotes: 2

Related Questions