We present a survey of the ortho-H2D+(1_{1,0}-1_{1,1}) line toward a sample of 10 starless cores and 6 protostellar cores, carried out at the Caltech Submillimeter Observatory. The high diagnostic power of this line is revealed for the study of the chemistry, and the evolutionary and dynamical status of low-mass dense cores. The line is detected in 7 starless cores and in 4 protostellar cores. N(ortho-H2D+) ranges between 2 and 40x10^{12} cm^{-2} in starless cores and between 2 and 9x10^{12} cm^{-2} in protostellar cores. The brightest lines are detected toward the densest and most centrally concentrated starless cores, where the CO depletion factor and the deuterium fractionation are also largest. The large scatter observed in plots of N(ortho-H2D+) vs. the observed deuterium fractionation and vs. the CO depletion factor is likely to be due to variations in the ortho-to-para (o/p) ratio of H2D+ from >0.5 for T_{kin} < 10 K gas in pre-stellar cores to ~0.03 (consistent with T_{kin} ~15 K for protostellar cores). The two Ophiuchus cores in our sample also require a relatively low o/p ratio (~0.3). Other parameters, including the cosmic-ray ionization rate, the CO depletion factor (or, more in general, the depletion factor of neutral species), the volume density, the fraction of dust grains and PAHs also largely affect the ortho-H2D+ abundance. The most deuterated and H2D+-rich objects (L429, L1544, L694-2 and L183) are reproduced by chemical models of centrally concentrated (central densties ~10^{6} cm^{-3}) cores with chemical ages between 10^4 and 10^6 yr. Upper limits of the para-H3O+ (1_1- -2_1+) and para-D2H+ (1_{1,0}-1_{0,1}) lines are also given. (Abridged)