I need to send the result of my stored procedure from the controller to the view.
This is on my controller:
using (SqlConnection con = new SqlConnection("data source=DESKTOP-99IPRRD;initial catalog=RecursosHumanos;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""))
{
SqlCommand cmd = new SqlCommand("sp_DeduccionesNombre", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter paraminicio = new SqlParameter();
paraminicio.ParameterName = "@inicio";
paraminicio.Value = FechaDesde;
SqlParameter paramfinal = new SqlParameter();
paramfinal.ParameterName = "@final";
paramfinal.Value = FechaHasta;
SqlParameter paramareID = new SqlParameter();
paramareID.ParameterName = "@areID";
paramareID.Value = Area.AreId;
SqlParameter paramarageID = new SqlParameter();
paramarageID.ParameterName = "@ageID";
paramarageID.Value = Agencia.AgeId;
cmd.Parameters.Add(paraminicio);
cmd.Parameters.Add(paramfinal);
cmd.Parameters.Add(paramareID);
cmd.Parameters.Add(paramarageID);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
This is my stored procedure:
drop procedure sp_DeduccionesNombre
go
create procedure sp_DeduccionesNombre @inicio datetime, @final datetime, @areID int, @ageID int
as
select distinct d.DedId, d.DedDescripcion
from Tbl_HistorialLaboral hl
inner join Tbl_Empleado e on e.empid = hl.EmpId
inner join Tbl_DetalleDeduccionesEmpleado de on de.EmpId = e.EmpId
inner join Tbl_Deducciones d on d.DedId = de.DedId
where hl.areID = @areID and hl.AgeId = @ageID
and (de.DetDedEmpFecha between @inicio and @final)
This is the result of my stored procedure that I try to show: