Get the the last inserted record in the code behind
<p>I have an insert stored procedure likes this </p>

<pre><code> insert into Profile_Master(FirstName,LastName,Dob,Gender,MobileNo,Country,State,EmailId,Password)
 values 
(@FirstName,@LastName,@Dob,@Gender,@MobileNo,@Country,@State,@EmailId,@Password)
set @id=SCOPE_IDENTITY()
return
end 
</code></pre>

<p>I want to get the last inserted record in the code behind,how to catch the value?</p>

<pre><code>            pid = cmd1.Parameters.Add("@id", System.Data.SqlDbType.Int);
            pid.Direction = System.Data.ParameterDirection.Output;
            int res = Convert.ToInt32(pid.Value);
            HttpContext.Current.Session["value"] = res.ToString();
</code></pre>

<p>here i am getting res as 0 so the values are not getting updated in the second page.</p>
