It happened, when David lived in his house, that David said to Nathan the prophet, Behold, I dwell in a house of cedar, but the ark of the covenant of Yahweh [dwells] under curtains.
The variations in the two accounts are not significant.  God's prohibition against David's intention of building God a house was stated in the form of a question in 2Samuel, but appears here as a positive commandment forbidding it.  The meaning is the same either way.  The Hebrew method of making a negative statement frequently took the form of a question as in  Luke 18:8.