title: Application keep old sql connection when switch database (C#)
body: <p>I have two SQL Server databases, server name are <code>sql1</code> and <code>sql2</code>.</p>
  
  <p>When I switch database from <code>sql1</code> to <code>sql2</code> (using HaProxy), my application still keeps the old SQL connection to server <code>sql1</code>.</p>
  
  <p>However, other applications (using Linq-to-SQL) can get the new SQL connection to <code>sql2</code>.</p>
  
  <p>Please see my code below that's I using to get connection to SQL Server:</p>
  
  <pre><code>using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString))
  {
      using (SqlCommand command = new SqlCommand())
      {
          conn.Open();
  
          //do something...
  
          conn.Close();
  
          return data;
      }
  }
  </code></pre>
  
  <p>What's my problem? How can I resolve this? Thanks!</p>