Has anybody come across ds.hasChanges() being false despite that the ds clearly has the changes while you check it at a breakpoint? I've been looking at it for quite a while and I can't see what is wrong...
// connectionstring and command has been set
DataSet ds = new DataSet();
BindingSource myBindingSource = new BindingSource();
SqlDataAdapter dataAdapter1 = new SqlDataAdapter();
dataAdapter1.Fill(ds, "Data");
myBindingSource.DataSource = ds.Tables["Data"];
// then changes made to the datatable on a windows form using bindingnavigator
ds.HasChanges(DataRowState.Modified); // is false
Now when I set a breakpoint after the row with HasChanges and use DataSet Visualizer I can see that the DataSet has in fact changed, but HasChanges still returns false.
I'm sure I'm missing the obvious... can anybody see what I'm doing wrong?
Cheers
Try calling the EndCurrentEdit() on BindingContext first:
DataTable dt = ds.Tables["Data"];
this.BindingContext[dt].EndCurrentEdit();
if(ds.HasChanges(DataRowState.Modified))
{
// do your stuff here
}
Also try calling the myBindingSource.EndEdit() that will push any un-commited data to the DataTable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With