To be able to write changes back to the data source, the DataAdapter object that populates your DataSet should have commands set for creating, reading, updating, and deleting. If you are using SQL Server, the class SqlCommandBuilder will generate these commands from a Select command. All you have to do is instantiate this class passing it in the data adapter that we use.
A complete sample is available here: simpledata4.zip
Command builder will generate the command required to update the datasource from your select statement:
SqlCommandBuilder commandBuilder = new SqlCommandBuilder( dataAdapter );
After this is done whenever you wish to write changes back to the data source simply call Update on the data adapter as shown below.
if( dataSet != null && dataSet.HasChanges() )
dataAdapter.Update( dataSet, "Customers" );
Contributed from George Shepherd's Windows Forms FAQ