Updating access database using datatable

For databases that do not support batching of SQL statements, resetting the primary key value on row updated event is a good workaround.

updating access database using datatable-58

Now if you are using MS Access database or SQL CE, you will see that the above walk through does not work as expected.

When you click the save, the primary key -1,-2,-3 keep unchanged.

While in your client application, you can insert a new row into a corresponding ADO.

NET Data Table (Data Table can be seen as the in memory cache of the data table in the database, I will use Data Table as the example in this post).

In most circumstances, however, you will bind to a Binding Source component which will manage the details of interacting with the data source.

The Binding Source component can represent any Windows Forms data source and gives you great flexibility when choosing or modifying the location of your data.

If you have an identity primary key column defined in a database table, its value will be automatically set by the database engine when you insert a new row to the table.

The identity value is determined by the column’s Identity Seed and Identity Increment properties.

If you check on the Table Adapter Configuration Wizard, the Refresh the data table option is disabled.

Tags: , ,