1) Merging changes from
mydatatable
into the very same
mydatatable
makes no sense, nothing will change, so it's not an error, just a waste of CPU cycles. So I suggest you remove
mydatatable.Merge(mydatatable.GetChanges());
2)
mydatatable.AcceptChanges();
calling
AcceptChanges
will set the state of all rows in the
DataTable
to Unchanged. So after this call there are no changes to commit to a database.
Remove
mydatatable.AcceptChanges();
and your code should work, assuming you've set the UpdateCommand and InsertCommand of the SqlDataAdapter either yourself or by using
OleDbCommandBuilder[
^]. If you haven't then have a look at this:
How To Update a SQL Server Database by Using the SqlDataAdapter Object in Visual C# .NET[
^]
It states it's for SQL Server but that's just a matter of difference in the SQLs the code is the same no matter which database you use.