God's conditional promise was that David & his descendants would remain in office as kings only when they honored & obeyed him. When David's descendants failed to do this, they lost the throne.
God's unconditional promise was that David's line would go on forever. This was fulfilled in the birth of Jesus Christ, a descendant of David who was also the eternal Son of God.
David, whose life exemplified obedience, gave well-seasoned advice to his son, the next king. It would be up to Solomon to follow it.
Reference summary used from the Life Application KJV Bible, Tyndale House Publishers, Inc., Wheaton, Illinois