title: Disconnect active SQL connections from SMO
body: <p>Is there a way to use SMO to disconnect all active users from a SQL database, so I can perform a database restore?</p>
  
  <p>The question linked to below is similar, but does not discuss the use of SMO.</p>
  
  <p><a href="https://stackoverflow.com/questions/1154200/when-restoring-a-backup-how-to-disconnect-all-active-connections">When restoring a backup, how do I disconnect all active connections?</a></p>
  
  <p>This link also is a similar question, but remains unanswered:</p>
  
  <p><a href="http://us.generation-nt.com/answer/smo-detach-fails-due-active-connection-help-122972951.html" rel="nofollow noreferrer">http://us.generation-nt.com/answer/smo-detach-fails-due-active-connection-help-122972951.html</a></p>