Update multiple tables
<p>I have 2 tables namely Profile and Info. </p>

<p>My table looked like this:</p>

<p>PROFILE</p>

<pre><code>| p_Id | FirstName | LastName |

| 1    | Jack      | Cole     | 
| 2    | Cynthia   | Cole     | 
| 3    | Robert    | Cole     |  
</code></pre>

<p>INFO</p>

<pre><code>| I_Id | childsID | fathersID | mothersID | Country |

| 1    | 1        | 3         | 2         | USA     |
</code></pre>

<p>I'm retrieving values from those tables by displaying them in textboxes, my select query is:</p>

<pre><code>SELECT p.p_Id, p.FirstName, p.LastName, i.*, 
(SELECT pp.FirstName+' '+pp.LastName FROM Profile pp WHERE pp.p_Id=i.childsID) AS child,
(SELECT pp.FirstName+' '+pp.LastName FROM Profile pp WHERE pp.p_Id=i.fathersID) AS father,
(SELECT pp.FirstName+' '+pp.LastName FROM Profile pp WHERE pp.p_Id=i.mothersID) AS mother
    FROM Info i
        INNER JOIN Profile p
            ON p.p_Id=i.childsID
</code></pre>

<p>no problem with select, I'm able to display values on textboxes, but the problem is, I can't update them, I have tried so far this:</p>

<pre><code>using (SqlCommand cmd = con.CreateCommand())
    {
        con.Open();
        cmd.CommandText = @"UPDATE Profile SET FirstName=@fname, LastName=@lname WHERE p_Id = @pid;
                            UPDATE Info SET childsID=@child, fathersID=@father, mothersID=@mother, Country=@country WHERE I_Id = @iid;";

        cmd.Parameters.Add(new SqlParameter("@fname", txtfname.Text));
        cmd.Parameters.Add(new SqlParameter("@lname", txtlname.Text));
        cmd.Parameters.Add(new SqlParameter("@child", txtchild.Text));
        cmd.Parameters.Add(new SqlParameter("@father", txtfather.Text));
        cmd.Parameters.Add(new SqlParameter("@mother", txtmother.Text));
        cmd.Parameters.Add(new SqlParameter("@country", txtcountry.Text));
        cmd.Parameters.Add(new SqlParameter("@pid", txtpid.Text));
        cmd.Parameters.Add(new SqlParameter("@iid", txtiid.Text));
        cmd.ExecuteNonQuery();
        Response.Write("alert('DATA UPDATED')");
    }
</code></pre>

<p>I'm using c# and Asp.net
Thanks in advance :) God Bless</p>
