We study the rheology of cornstarch suspensions, a non-Brownian particle system that exhibits shear thickening. From magnetic resonance imaging velocimetry and classical rheology it follows that as a function of the applied stress the suspension is first solid (yield stress), then liquid, and then solid again when it shear thickens. For the onset of thickening we find that the smaller the gap of the shear cell, the lower the shear rate at which thickening occurs. Shear thickening can then be interpreted as the consequence of dilatancy: the system under flow wants to dilate but instead undergoes a jamming transition because it is confined, as confirmed by measurement of the dilation of the suspension as a function of the shear rate.