Rebbe,
When the gemara says that anyone who says Dovid Hamelech sinned is mistaken it refers to the story of Batsheva and the story of Mefiboshet and Tzeeva. Why does the gemara not discuss the case in which Dovid Hamelech counted the people against Yoav's advice and apparently against Torah law and thereby precipitated a plague in which thousand of Jews died?
B'kavod,
Sam Kosofsky
Your Kashya must be a good one, because Tosfos DH 'Rak' ask it.
They answer
a. That the sin of 'Hasasah' as it is known, as was not per se such a serious sin (notwithstanding the devastating punishment). Certainly, it does not match that of adultery.
b. It was b'Shogeg.
R. Eliezer Chrysler