Added a check for DoQuery to see if the db has established a connection.