MainWindow: Fix possible endless loop in executeQuery

Don't get into an endless loop when there is a syntax error in the SQL
statement to execute.
Merge pull request #12 from MKleusberg/master

Bugfix in executeQuery