If both have HDMI that should be the first option. Second, Optical (TosLink) connections, last RCA/Stereo.
It will help to know model numbers of both TV and sound bar since there are plenty Sharp TVs and half a dozen Magnavox sound bars with different audio connections (Optical, Stereo, RCA, HDMI, etc).