Fixed crash when trying to execute a query without a database open.