For extra effectiveness: put cellophane over the sugar water jar and poke a few holes in it with a pencil. (For fruit flies, use a toothpick). They smell it and get in via the hole, but they can't find their way back out.
Abusive comment hidden.
(Show it anyway.)