The gemara says that according to the one who says Dovid’s question had to do with paying for something that was damaged by fire and was hidden, we need to understand what it means that “Dovid did not drink the waters.” This would seem to imply that he did not do as was told to him through these messengers who had asked the question to the Sanhedrin! The gemara explains that he certainly did as he was told, but he did not say the halacha over in the name of those who risked their lives to receive this answer, as he had learned from Shmuel hanavi.
In searching for a pshat in this, I came across a very interesting site in Hebrew that speaks about this. There he says that we find that it is actually a good thing for someone to ‘kill himself’ for the Torah, so why does he not have it said in his name? The way I understand the answer, the understanding of it is that when a person totally negates himself – “kills himself” – for the Torah, so in essence he shows that it is not important to him that his own name be mentioned in connection to the Torah he is teaching. It is actually much greater than that, because now the concept is said over in the name of ‘the Gemara’ – meaning, it is said over as if it is a halacha l’Moshe mi’Sinai. Thus the person has brought down and restored the Torah to its former glory. Can there be any greater reward for one who ‘kills himself’ over the Torah?