One tip a professor gave me is to ask, "Would you be able to give me a positive letter of recommendation?"
You don't want just any letter, it needs to advance your cause.
It seems like you would not ask somebody you were not sure of, but people do. As you said, if the person is less than enthusiastic about writing the letter, you don't want that letter!