When I'm using Management Studio Express to drop a database there is an checkbox "Close existing connections." which close open database and enforce it to drop.
How can i drop a database programmatic by closing open connections and check it's ever exists before?