title: Can update two tables using join operation in SQL Server?
body: <p>In my web application using asp.net I have a gridview with edit button. This gridview is created by joining two tables. I need to update those two tables when I click those edit button..
  My gridview consists 3fields- name,nric,and status.where the name and nric from table 1 and status from table2. How will be the query to update both tables ?
  Please help</p>
  
  <pre><code> protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
  {
      GridView1.EditIndex = -1;
  }
  protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  {
     GridView1.EditIndex = e.NewEditIndex;
  }
  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
      GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
  
      TextBox id = (TextBox)row.FindControl("s_id");
      TextBox name = (TextBox)row.FindControl("s_name");
      TextBox nric = (TextBox)row.FindControl("s_nric");
      TextBox status = (TextBox)row.FindControl("s_status");
      SqlConnection con = obj.getcon(); 
      con.Open();
      SqlCommand cmd = new SqlCommand("update e.student_details ,f.student_vs_testsession_details  set e.student_id='" + id.Text+ "',e.student_name='" + name.Text + "',e.student_nric='" + nric.Text + "',f.testsession_status='" + status.Text + "' where e.student_id=f.student_id", con);
      cmd.ExecuteNonQuery();
      con.Close();
  
  
  }
  </code></pre>