title: C# MySQL Connection Pooling
body: <p>I am having <code>C# multi threading</code> application and using <code>MySQL</code> with single connection to whole application. But when two or more thread try to access database at the same time, then i get below error :</p>
  
  <blockquote>
    <p>There is already an open <code>DataReader</code> associated with this <code>Connection</code> which must be closed first.  </p>
  </blockquote>
  
  <p>My Connection code is below </p>
  
  <pre><code>public static _connectionSetup = new MySqlConnection("Server=server ; Database=database;User ID=user;Password=pass;Pooling=true;");
  </code></pre>
  
  <p>and when i need to use connection i am using below code :- </p>
  
  <pre><code>using (MySqlConnection connection =_connectionSetup )
  {
      using (MySqlCommand command = new MySqlCommand("proc", connection))
      {
          ....
      }
  }
  </code></pre>
  
  <p>I tried used <code>pooling=true</code> and i have create two separated connection as well for two different thread, but still i am getting above error.<br>
  Am I missing something?</p>
  
  <p>How can I implement connection pool so that all thread will use separate connection  and won't cause any issue?</p>