I had the same problem, but I asked for advice on here got some of the best. I fixed the problem for around $120.00, I replaced both the transmission range sensor (easy swap, sits right on top of the tranny), and the VSS - speed sensor, behind the instrument panel. They work together with the tranny, if one is out or bad it throws the whole system out of whack. Hope this helps.
Beaz
'97 Contour