Fix an issue with executeScalar.

Connection was not open at the point executeScalar was called.
Refactored to match the execute method. That is Open is not called until
just before execute and then only if connectionState is not already
open. I'm assuming there is some issue with calling Open on an already
open connection.