i have a stored procedure which returns a parameter containing string in it i don't know how to call it and get the output parameter to show on my view
ALTER PROCEDURE [dbo].[sp_test]
@room_type varchar(40)
,@room_price_min float
,@room_price_max float
,@room_number varchar(30)
,@new varchar(50) output
as
;
--select @room_no
if exists(select room_number from Rooms_ms where room_number=@room_number)
begin
set @new='Room Already Exists'
select @new
return
end
insert into Rooms_ms(room_type,room_price_min,room_price_max,room_number) values
(@room_type,@room_price_min,@room_price_max,@room_number)
set @new='Successfully'
select @new
return
I'm trying to catch it like below but don't know how to exactly do it.
var result= db.sp_test(a, b, 0, c);
Thank you
You can implement the following to retrieve the data for a stored procedure call
using(var db = new iConext())
{
var details = db.Database.SqlQuery<iType>("exec iProc @param", new SqlParameter("@param", iValue));
}
iType
is int or string or long or can be a ComplexType@param
is one or more required parametersiContext
is for your db connection