Fixed a bug where the SQL connection wouldn't be open in certain method.