Fixed exception if no database select is possible, closes #771