Working on my first mvc(5) asp.net web application. I am using data entity framework. I have a stored procedure, 'usp_EventInsert' which takes HevEventID, HemEmployeID and HevEventDescription:
@HevEventID int,
@HemEmployeID int,
@HevEventDescription varchar(150)
SET NOCOUNT ON
SET XACT_ABORT ON
INSERT INTO [dbo].[RhEvent] ([HevEventID],[HemEmployeID],[HevEventDescription])
SELECT @HevEventID, @HemEmployeID, @HevEventDescriptionID
In my code, I want to insert an event in the table and check if it was successful. I am calling it this way, for example:
myDBcontext.usp_EventInsert(123,112345,"some description")
I was expecting to be able to fetch the HevEventID(or HemEmployeID or HevEventDescriptionID) once the stored procedure is called. For example, I tried:
var event = myDBcontext.usp_EventInsert(123,112345,"some description")
I was expecting to find the elements in the select inside 'event'. But event = -1 when I try that. Not only event doesn't have any of the select data in it, it's value is -1(From what I read SET NOCOUNT ON causes that?), which seems odd to me since the stored procedure was successful (new row being inserted in the table).
any suggestions on how I can be sure the stored procedure was successful? Without doing a select on the table..