I tried those. Last year we had so many fruit flies or drain flies or gnats or whatever the hell they are that my son was losing his mind. He still hallucinates seeing them sometimes! Or imagines it, anyway.
We tried everything. In the end the only way to get rid of them was by cleaning the hell out of the house and denying them anything they could possibly use for food. That got rid of them completely.