you bind the values from the database (using the dataAdapter) to the
datagridview and set the datagridview datasource to the dataset
defaultview:
this.theDataGridView.DataSource = theDataSet.Tables[0].DefaultView;
then when you add rows to the datagridview, simply call the Update()
command on the dataAdapter which will update the database automatically.
you could manually add a new row in the dataTable, and add columns
of data then re-bind the dataGridView to the dataset, since it will
have an updated set of records, then to finally commit the changes to
the database, simply call the Update() command on the dataAdapter.
To add a row in the datatable:
theDataSet.Tables[0].Rows.Add(objectValues);
theObjectValues are a collection of objects which bind the values to the columns, so if we had 2 columns we would do this:
object[] theRecord = new object[] { "Column1Value", "Column2Value" };
theDataSet.Tables[0].Rows.Add(theRecord);
this.theDataGridView.DataSource = theDataSet.Tables[0].DefaultView;
//then commit to database:
theDataAdapter.Update();