Dear student,
Sodium chloride in solution ionizes to form sodium and chlorine ions, these ions are responsible for conducting electricity. In crystal, sodium and chlorine ions are held together strongly and are not free to conduct electricity.
Regards.