5
I’m having a problem, which would be a mistake saying that there is no parameter being passed to the Procedure.
It is running the following code:
cmdProcedure.Parameters.AddWithValue("@id", 0);
Command:
public List<Models.Admin> UpdateList()
{
using (var context = new DbContext())
{
var cmdProcedure = new SqlCommand("GetAdmin");
cmdProcedure.Parameters.AddWithValue("@id", 0);
using (var data = context.ExecuteSelectProcedure(cmdProcedure))
{
return GetList(data);
}
}
}
public SqlDataReader ExecuteSelectProcedure(SqlCommand cmdProcedure)
{
cmdProcedure.Connection = _connection;
return cmdProcedure.ExecuteReader();
}
Here is my trial:
PROCEDURE [dbo].[GetAdmin]
(
@id int
)
AS
BEGIN
SET NOCOUNT ON;
if (@id > 0)
SELECT * FROM Admin WHERE idAdmin = @id
else
SELECT * FROM Admin
END
Error image:
Luiz, please accept your answer as correct so the question is not pending. Hug!
– Andre Calil
It’s only 9:00 so I can still do this hehe.
– Luiz Negrini
Sorry, I forgot this =P
– Andre Calil