Al-Adab Al-Mufrad, Book 2, Hadith 24 (In-Book)

Hakim ibn Hizam said to the Prophet, may Allah bless him and grant him peace, "Do you think that the acts of worship which I used to do in the time of the Jahiliyya - maintaining relations with relatives, setting slaves free and sadaqa - will bring me a reward?" Hakim said that the Messenger of Allah, may Allah bless him and grant him peace, said, "When you become Muslim, you keep the good actions you have already done."

حَدَّثَنَا أَبُو الْيَمَانِ، قَالَ‏:‏ أَخْبَرَنَا شُعَيْبٌ، عَنِ الزُّهْرِيِّ قَالَ‏:‏ أَخْبَرَنِي عُرْوَةُ بْنُ الزُّبَيْرِ، أَنَّ حَكِيمَ بْنَ حِزَامٍ أَخْبَرَهُ، أَنَّهُ قَالَ لِلنَّبِيِّ صلى الله عليه وسلم‏:‏ أَرَأَيْتَ أُمُورًا كُنْتُ أَتَحَنَّثُ بِهَا فِي الْجَاهِلِيَّةِ، مِنْ صِلَةٍ، وَعَتَاقَةٍ، وَصَدَقَةٍ، فَهَلْ لِي فِيهَا أَجْرٌ‏؟‏ قَالَ حَكِيمٌ‏:‏ قَالَ رَسُولُ اللهِ صلى الله عليه وسلم‏:‏ أَسْلَمْتَ عَلَى مَا سَلَفَ مِنْ خَيْرٍ‏.‏

sunnah.com