Sodium chloride is an ionic compound. It is made of sodium ions which have lost an electron to become positively charged (Na+) and chloride ions which have gained an electron to become negatively charged (Cl-).
Ionic compounds such as sodium chloride are arranged in a giant three-dimensional lattice structure, which is a regular repeating pattern of positive and negative ions. There are strong electrostatic forces of attraction that hold the oppositely charged ions together in the giant lattice. These forces act in all directions of the lattice and form ionic bonds.
It takes a large amount of energy to overcome the strong electrostatic forces of attraction in an ionic compound and therefore they often have high melting and boiling points. This is the case with sodium chloride which has a melting point of 801°C. Ionic compounds such as sodium chloride can only conduct electricity when they are melted or dissolved in water. They cannot conduct electricity when they are solid because the ions are not free to move around and carry an electrical charge.