The promise to David was that his seed would build the LORD's house:
"And it came to pass that night, that the word of the LORD came unto Nathan, saying, Go and tell my servant David...I will set up thy seed after thee, which shall proceed out of thy bowels, and I will establish his kingdom. He shall build an house for my name, and I will stablish the throne of his kingdom for ever. I will be his father, and he shall be my son. If he commit iniquity, I will chasten him with the rod of men, and with the stripes of the children of men: But my mercy shall not depart away from him, as I took it from Saul, whom I put away before thee. And thine house and thy kingdom shall be established for ever before thee: thy throne shall be established for ever" (2 Sam.7:5, 12-16).
And that truth is confirmed by David here:
"And of all my sons, (for the LORD hath given me many sons,) he hath chosen Solomon my son to sit upon the throne of the kingdom of the LORD over Israel. And he said unto me, Solomon thy son, he shall build my house and my courts: for I have chosen him to be my son, and I will be his father" (1 Chron.5:6).