If a landlord sells the building, the new owner may or may not raise the rent.
The new owner takes all of the rights of the old owner – no more and no less. So take a look at the answer to “When and how often may a landlord raise the rent”. Same answer. If you have a lease, the new owner is stuck with it. If you have a month-to-month rental agreement, the new owner may raise the rent as much and as often as he likes, so long as he gives proper notice and doesn’t violate a local rent control law.