Please clarify. Are we talking about a female or male?
If you are talking about a female, the only way to prevent mating is to keep her away from male dogs for the entire time she is in heat which is approx. three weeks.
Let me know if you have additional questions or can provide more info.