I have created an application to fix a date conversion problem when transferring data from the machines. The conversion works great. I create a DataGridView that contains all records. I then sort the DataGridView to display the data that needs updating using SqlDataAdapter and DataSet. I then make the changes to the data in the DataGridView and click a save button to apply changes to the database table.
try
{
MessageBox.Show("Complete");
this.log5DataGridView.EndEdit();
//this.log5BindingSource.DataSource = this.log5DataGridView.DataSource; <-- Last Resort
this.log5BindingSource.ResetBindings(false);
this.log5BindingSource.EndEdit();
this.log5TableAdapter.Update(roboticlineDataSet.Log5);
}
catch { }
When I run in debug mode the log5DataGridView.DataSource Table[] shows the data changes are available. But the log5BindingSource never seems to get the changes to push it through to the TableAdapter Update. I tried the ResetBindings, EndEdit() the last thing is to take the Datasource and force it to the BindingSource.
If I use the following code to search for the precise record the save / update to database will not occur.
using (SqlDataAdapter adpt = new SqlDataAdapter("SELECT * FROM [dbo].[RoboticLine] WHERE [FSItemNumber] = '" + Value + "' ORDER BY [FSItemNumber] ASC;", conn))
{
DataSet ds = new DataSet();
adpt.Fill(ds);
valueComboBox.Enabled = false;
log5DataGridView.DataSource = ds.Tables[0];
log5DataGridView.Refresh();
this.log5DataGridView.Rows[0].Selected = true;
}//end of adpt using
The Question is if there is a way to save the searched log5DataGridView record back to the database as the datagridview table retains the change but the log5BindingSource still contains the original
this.log5TableAdapter.Fill(this.roboticlineDataSet.Log5);
Thank you.