title: Can not call sp_detach_db on a database that is offline
body: <p>I can run this command in SqlManager to detach the db</p>
  
  <pre><code>ALTER DATABASE mydb SET OFFLINE WITH ROLLBACK IMMEDIATE
  
  GO
  
  dbo.sp_detach_db @dbname = N'mydb',@keepfulltextindexfile = N'false'
  </code></pre>
  
  <p>When I use the same connection running the same commadn via ado.net fails with error:</p>
  
  <pre><code>The database 'mydb' can not be opened because it is offline 
  </code></pre>
  
  <p>(Error is translated from german.)</p>
  
  <p>The Ado.Net code is</p>
  
  <pre><code>            SqlCommand cmdOffline = new SqlCommand(@"ALTER DATABASE mydb SET OFFLINE WITH ROLLBACK IMMEDIATE");
              cmdOffline.Connection = prepareMasterDBConnection;
              cmdOffline.ExecuteNonQuery();
  
  
              SqlCommand cmdDetach = new SqlCommand(@"dbo.sp_detach_db @dbname = N'mydb',@keepfulltextindexfile = N'false'");
              cmdDetach.Connection = prepareMasterDBConnection;
              cmdDetach.ExecuteNonQuery();
  </code></pre>
  
  <p>The connection is set to master - DB and open. The first commadn exceutes sucessfully.</p>
  
  <p>What is the difference here when calling the code from ado and from sql-manager?</p>