I use the Chirp virtual keyboard which comes with LoopBe.
I don't understand why you're opening Sonar twice. What I think you should be doing is to first start up your virtual midi cable/patchbay, fire up you virtual keyboard and set its output to a channel in the cable/patchbay _then_ start up Sonar and select the same channel in Sonar -> Preferences -> Midi -> Devices.
Then set the input of your synth to the same device.
Turn on input echo on the track and things should work.
As brundlefly mentions, a virtual midi keyboards is of limited usefulness, especially since it will constantly lose focus everytime you click on sonar. It's ok for situations where you just want to putter around auditionning sounds while sitting on a plane or something.
Many softsynths already accept some limited pc keyboard note entry, so you may not even need a virtual midi keyboard.