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);
}
}
您不需要将更改保留在代码中的数据库中,您需要调用:
ContactsDataAdapter.Update()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.