The sand covering is said to prevent access for the laying of more eggs. If gnats have access to drain holes, that won't prevent the adults from being attracted to pots. Sand on the surface will migrate down into any tiny air spaces whenever you water, possibly causing roots to suffocate & rot (overwatering) over time. IDK what the gnats might think about it, but putting tiny particles like sand in pots is a recipe for inviting root rot.