Madito Kevin

Madito Kevin

  • NA
  • 8
  • 1.9k

Update database record

Apr 26 2015 1:34 PM
i want to update tables for my database when i update one record from a table the second table must be updated automatically.
 
 below is update button for my first table
 
private void btn_Update_Click(object sender, EventArgs e)
{
try
{
System.Data.DataTable dt2;
dt2 = ds.Tables["tblForce_N"];
this.assetdg.BindingContext[dt2].EndCurrentEdit();
this.da.Update(dt2);
MessageBox.Show("Data Update successfull", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
 
 
here is update button for my second table
 
private void button1_Click(object sender, EventArgs e)
{
try
{
System.Data.DataTable dt2;
dt2 = ds2.Tables["tblComp"];
this.assetdg.BindingContext[dt2].EndCurrentEdit();
this.da2.Update(dt2);
MessageBox.Show("Data Update successfull", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
when i click update from one table i want the second table to be updated automatically ,i'm using datagridview not text boxes to enter records. 

Answers (3)