Now if you using the alesis then I pretty sure you goin to have problems...I went to a church and they had a alesis and i tried to use it for my b4 program (WIth USB Midisport) and no luck whatsoever...all you need is midi out plugged in your keyboard and that's it.
For Sonar go to options--->MIDI Devices and make sure that your midi cord is highlighted in the INPUT area and Microsoft GS Wavetable Synth for the OUTPUT. For Cubase...I have no idea, although I have the program I never use it...don't like it at all LOL!