Generally when something like that happens to me, it's been because of a damaged or loose connection between the USB jack and the little circuit board it's mounted on. If you're feeling brave, I would suggest you open up the flash drive in order to inspect the jack and printed circuit. That will probably mean splitting open the glued plastic case, which you may or may not be able to do non-destructively.
Once you have it open, look at where the USB port connects to the circuit board. The connections need to be secure against the traces on the board; if there's any movement whatsoever then the soldering has failed and needs to be redone. It's also possible the traces have broken and would need a bit more intensive repair, but there's no way of knowing without seeing pictures. I'd suggest opening it up and taking some high resolution pictures then adding them to your question and we'll see what we can do.
Adding images to an existing question - iFixit Repair Guide