Notts completely controlled the first half, with Sam denied by Sam Walker before Lee Hughes' header and shots from Alan Judge, Daniel Bogdanovic and Sam again all went wide.
But in the 37th minute, Julian Kelly crossed into the area, and Paul Huntington's clearance only went as far as Jeff Hughes, who set up Sam to open the scoring with a low finish.
After the break, Notts held sway again but could not find a second goal, despite efforts from Neal Bishop and Judge.
Jonathan Franks looked to have made them pay 11 minutes from time when he levelled the scores with a close-range strike.
But Sam put County ahead again with three minutes to go before making sure of the points after being set up by substitute Dele Adebola.