Reputation: 11
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
Reputation: 6152
You don't persist the changes back to the database in your code, you need to call:
ContactsDataAdapter.Update()
Upvotes: 2