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 procedure:
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: