Miscarriage

I went to the doctor today, and found out my baby has no heartbeat. My husband and I are devastated to say the least! I should be 10 weeks and the baby measured 8w 3D. I'm scheduled for a d&c next week, but I'm terrorified that I will have a miscarriage before the procedure. How long can the baby be in me before it passes??? Help!