I have this method to execute stored procedures
public void EjecutarSP(string sp)
{
try
{
SqlCommand cmd = new SqlCommand(sp, ConexionBD.con);
cmd.CommandType = CommandType.StoredProcedure;
ConexionBD.Conectar();
cmd.ExecuteNonQuery();
ConexionBD.Desconectar();
}
catch (Exception ex)
{
throw new Exception(" Error al ejecutar procedimiento almacenado ", ex);
}
}
This method serves me generically when the stored procedures do not receive or return any value, I wanted to know if there is any way to make them generic for when the stored procedure receives and returns parameters, I believe that for the return part I can use ExecuteReader that it returns a table and then work it in the application, but for the parameter sending part, I do not know if something generic can be done since not all the stored procedures receive the same amount of parameters.