how to get the ID of the record that is update in C#
<p>I am able to get a sql query that can return the ID of a record that is update in the Database; that ID is needed to update other records.</p>
<pre><code>public int updateCases(int id,string fname)
{
 string query=&quot;update bio_data set firstName=@fname OUTPUT INSERTED.ID where id=@ID&quot;;
    int IDValue = 0;
    try
    {
        con.Open();
        SqlCommand cmd = new SqlCommand(query, con);
        cmd.Parameters.AddWithValue(&quot;@ID&quot;,id);
        cmd.Parameters.AddWithValue(&quot;@fname&quot;,fname);
        
        IDValue = Convert.ToInt32(cmd.ExecuteNonQuery());  // this is incorrect because it always return one
        if (IDValue &lt;= 0)
        {
            return 0;
        }
        return IDValue; 
    }
    catch (Exception ex)
    {
        error.Text = &quot;An Error Occur while update a case Bio_data!!&quot; + ex.Message;
        error.ForeColor = Color.Red;
        return 0;
    }
    finally
    {
        con.Close();
    }
</code></pre>
<p>but I don't know how to get that updated ID value in C#.</p>