I have a stored procedure:
ALTER PROCEDURE [dbo].[pr_Tbl_Test_Insert]
@guidid uniqueidentifier output,
@sname nvarchar(50)
AS
-- INSERT a new row in
Before you execute the query you need to specify the direction of the parameter, in this case output. e.g.:
cmd.Parameters.AddWithValue("@guidid",_id);//_id is SqlGuid
cmd.Parameters.AddWithValue("@sname", "mehdi");
cmd.Parameters["@guidid"].Direction = ParameterDirection.Output
cmd.ExecuteNonQuery();
MessageBox.Show(cmd.Parameters["@guidid"].Value.ToString());