P
PeterZ
Hi,
I have win forms project, a single dataset named "dsAllTables" holding 4
tables. I have a seperate dataAdapter for each table named "daTable_#".
I know I can detect if the dataset as a whole has changes, but how do I
detect which specific table in the dataset has changes?
This is something I want to do, obviously it won't compile becase there's no
HasChanges() method on a table:
------------------------------------------------------------------
private void btnSave_Click(object sender, System.EventArgs e)
{
this.BindingContext[dsAllTables, "TABLE_1"].EndCurrentEdit();
this.BindingContext[dsAllTables, "TABLE_2"].EndCurrentEdit();
this.BindingContext[dsAllTables, "TABLE_3"].EndCurrentEdit();
this.BindingContext[dsAllTables, "TABLE_4"].EndCurrentEdit();
try
{
if (dsAllTables.Tables["TABLE_1"].HasChanges()) //<-- how do I achieve
this?
this.daTable_1.Update(this.dsAllTables.Tables["TABLE_1"]);
if (dsAllTables.Tables["TABLE_2"].HasChanges())
this.daTable_2.Update(this.dsAllTables.Tables["TABLE_2"]);
if (dsAllTables.Tables["TABLE_3"].HasChanges())
this.daTable_3.Update(this.dsAllTables.Tables["TABLE_3"]);
if (dsAllTables.Tables["TABLE_4"].HasChanges())
this.daTable_4.Update(this.dsAllTables.Tables["TABLE_4"]);
this.dsAllTables.AcceptChanges();
MessageBox.Show("All changes saved");
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message, "Saving changes failed.");
}
}
------------------------------------------------------------------
Appreciate any ideas!
Cheers,
PeterZ
I have win forms project, a single dataset named "dsAllTables" holding 4
tables. I have a seperate dataAdapter for each table named "daTable_#".
I know I can detect if the dataset as a whole has changes, but how do I
detect which specific table in the dataset has changes?
This is something I want to do, obviously it won't compile becase there's no
HasChanges() method on a table:
------------------------------------------------------------------
private void btnSave_Click(object sender, System.EventArgs e)
{
this.BindingContext[dsAllTables, "TABLE_1"].EndCurrentEdit();
this.BindingContext[dsAllTables, "TABLE_2"].EndCurrentEdit();
this.BindingContext[dsAllTables, "TABLE_3"].EndCurrentEdit();
this.BindingContext[dsAllTables, "TABLE_4"].EndCurrentEdit();
try
{
if (dsAllTables.Tables["TABLE_1"].HasChanges()) //<-- how do I achieve
this?
this.daTable_1.Update(this.dsAllTables.Tables["TABLE_1"]);
if (dsAllTables.Tables["TABLE_2"].HasChanges())
this.daTable_2.Update(this.dsAllTables.Tables["TABLE_2"]);
if (dsAllTables.Tables["TABLE_3"].HasChanges())
this.daTable_3.Update(this.dsAllTables.Tables["TABLE_3"]);
if (dsAllTables.Tables["TABLE_4"].HasChanges())
this.daTable_4.Update(this.dsAllTables.Tables["TABLE_4"]);
this.dsAllTables.AcceptChanges();
MessageBox.Show("All changes saved");
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message, "Saving changes failed.");
}
}
------------------------------------------------------------------
Appreciate any ideas!
Cheers,
PeterZ