It'll be hard to say without looking at the solution but here's a shot in the dark:
You seem to be using InfoPath.ExternalApplication, this is an ActiveX object used to automate InfoPath rich client. Since it does not exist on the server, it will not work. Even if you did install InfoPath on the server it probably wouldn't do what you expect to do.
For the SQL question, I believe it should work although I have not tried it myself. You might need to do some configuration first:
- Go to Sharepoint Central Administration
- Select Application Management, Configure InfoPath Forms Services and check the "Allow embedded SQL authentication" checkbox
Good luck!
David Airapetyan / Software Services ArchitectQdabra® Software / Streamline data gathering to turn process into knowledge