2
Hello, I’m performing an insert in a table, but I need it to return the ID you just entered. I searched on the command OUTPUT
but I couldn’t solve my problem. I need to do all this using procedures, IE, I also need to know how to "catch" this return from the process.
Procedure:
CREATE PROCEDURE SaveProfessionalUser
@id int,
@title varchar(50)
AS
BEGIN
INSERT INTO ProfessionalType VALUES (@title)
END
Codebehind:
using (_context)
{
SqlCommand cmd = new SqlCommand("SaveProfessionalUser");
cmd.Parameters.AddWithValue("@idProfessionalUser", pUser.IdProfessionalUser);
cmd.Parameters.AddWithValue("@title", pUser.Title);
cmd.CommandType = CommandType.StoredProcedure;
this._context.ExecuteProcedure(cmd);
return true;
}
You are doing with Entity Framework ?
– user6026