Application of the sampling theorem to boundary value problems