Fixed crash on sql query.