You have to update the underlying DataTable
. The DataGridView.Update
causes the control to redraw the invalidated regions within its client area (basically repaints). The dt.AcceptChanges()
only commits the changes in the DataTable not the database. The database has to be updated explicitly using the adapter and appropriate command texts. The OleDbCommandBuilder
helps in forming the appropriate command texts.
Use the OleDbDataAdapter
to update the database.
OleDbCommandBuilder cb = new OleDbCommandBuilder(adapter);
cb.QuotePrefix = "[";
cb.QuoteSuffix = "]";
adapter.Update(datatable);