Problem: David appears to contradict himself in the same psalm. First he says to God, “I have not strayed from Your precepts” (v. 110). But later he admitted, “I have gone astray like a lost sheep” (v. 176). However, it would seem that both cannot be true.
Solution: David has two different things in mind. In the first case he is speaking in general, and in the latter he is speaking in particular. In verse 110 David states that the general trend of his life has been faithfulness to God. But, in verse 176, David affirms what we must all acknowledge, namely, the universal truth that “all we like sheep have gone astray” (Isa. 53:6). So understood, there is no real contradiction here. (See also comments on 1 Kings 11:4.)