Although it would be wonderful to be able to write a story, submit the first draft, and have it accepted for publication right away, this isn’t likely. The odds of lightning striking the same place twice would be more favourable.
What this means, is that a writer should be persistent, but also flexible. If a piece gets rejected (for whatever reason) by several publications in the same genre, it might be a good idea to recast the story in a different one if possible. For example, let’s suppose you have written a science fiction action story with a Dashing Hero, a Mission of Utmost Importance, a Despicable Hero, and a Really Cool Spaceship. The idea is sound, the story flows well, the dialogue is well crafted, and there is an appropriate balance of action, tension, and a bit of humour. Unfortunately, despite being well written no publisher will take it. Does that mean you should abandon it? No!
The elements of the very rough plot outline provided above could easily be recast as a western (make the spaceship a trusty steed), a fantasy story, a high seas adventure (the ship is now a sailing vessel), or an espionage thriller (you might even be able to keep the spaceship). Naturally, you should pick a new genre that interests you, but you should also do a bit of market research to help you make your decision. Is the new genre saturated right now? Are there any red-hot new series out there that might overshadow your work? A diligent search, including visiting publishers’ websites, can help answer these questions, and others you might have. If all else fails, you can always contact the company or send a query letter, to gauge their interest.
All this to say, if your manuscript seems to be going nowhere, don’t be so quick to throw it away. All it might need is a little recasting.