Unable to perform database query