Fixed mysql error handling

- Fixed issue when SQL statement is invalid
- Fixed user interrupt (when user presses cancel)