 Denny was elected as an Anti-Masonic candidate to the Twenty-first Congress to fill the vacancy caused by the resignation of William Wilkins.He was reelected to the Twenty-second through Twenty-fourth Congresses and served from December 15, 1829, to March 3, 1837.After his term, he resumed the practice of law in Pittsburgh, and became a delegate to the Pennsylvania State Constitutional Convention in 1837.