Diatomaceous earth works by drying out the bodies of the insect. It also keeps the surface of the media dry, and that helps with gnats. It will add calcium and also raise the Ph of your medium. That may be a good thing or a bad thing, depending on where you are at.

1/2" of fine sand is good for the same reason....it dries the surface and keeps gnats at a minimum.

Tobacco (nicotine) is an MAO inhibitor in insects and is deadly to insects as well as humans. Powdered tobacco (wild tobacco that is 100X more potent than the smoking kind) is an effective insect dust and will not harm your plants. In a solution it becomes a little more dangerous but is a fine insecticide. If you ahve a lot of dust on top of the media and water it down it will burn your roots and may cause problems.

Pyrethrum and Neem are the two natural methods for contol that work really well. No need to spray the plant itself...just the pots and the area, and some light misting on top of the soil where the gnats live and breed. they are sure fire, used extensively in the cultivation of medical cannabis (as wellas food crops).

I am going to try a yellow post-it note standing up on the side of the pot, sprayed with pyrethrum. No actual contact with medium or plant, and I have been told it works like a charm. You could even use something a lot stronger like diazinon since there is no spray or contact with the plant or soil.