Not all questioning by the police requires Miranda warnings
There is a big difference between being "detained" and being "arrested" or "in custody" when it comes to Miranda. The 1966 US Supreme Court decision makes it mandatory that when a person is "in custody" and being interrogated, they must first be advised of their constitutional rights. During a detention, they are not required to give you the same rights, no matter how incriminating the questions and answers may be.
So - what's a detention?
If the police have "reasonable suspicion" of criminal activity and your connection to that crime, they can detain you. A detention is a temporary infringement of your ability to leave while the investigate whatever the matter is. For example, take the most common detention example: A traffic stop. The police clock you going 70 in a 65 zone. They have "reasonable suspicion" that a crime (even a traffic infraction) is going on and they can detain you for that investigation. If they walk up and smell alcohol, they can then investigate the new crime they've discovered. You're still only "detained" and may not necessarily have to have your rights given to you.
When are the rights required? (part 1)
When you're "in custody." "Custody" for the purpose of Miranda means a formal arrest of the functional equivalent of one. If they tell you you're under arrest, obviously, you're in custody. The police can say or do other things that are short of a formal arrest, but may significantly change your legal status from detained to "in custody" and make the Miranda warnings required.
When are the rights required? (part 2)
But just being "in custody" doesn't mean you have to have your rights read to you. You also have to be subject to interrogation. "Interrogation" is direct questions of you about the criminal activity you're suspected of or conduct which is "likely to elicit an incriminating response" from you. Obviously, if you're arrested for DUI and they want to ask you how much you had to drink, that answer would tend to incriminate you, so they have to give you your rights first. Note that that same exact question on the side of the road during a DUI investigation would more than likely be determined to be during a detention, but you would not be "in custody" so the answer would be admissible in court.
What if there is a Miranda violation? Is my case thrown out?
Unfortunately, not necessarily. The sanction for a Miranda violation is that any resulting statement is excluded from the prosecution's case. If that statement itself led to other incriminating evidence that they wouldn't have discovered except for your statement, then that may be excluded as well. If the statement is excluded, but the prosecutor has enough otherwise admissible evidence, then the case can go forward - just without your statement.