title: Too Many Clients Already in C# and PostgreSQL
body: <p>I have error "Too Many Clients Already" in C# and PostgreSQL
  Am I did something wrong?</p>
  
  <p>this is my main code </p>
  
  <pre><code>public class NationalService
  {
      private NpgsqlConnection conn;
      protected string query;
      public NationalService()
      {
          this.conn = ConnectionService.GetConnection();
      }
  
      public string GetNamaWilayah(string kodePropinsi, string kodeKabupaten)
      {
          this.query = "select namakabupaten from dim_gab_wilayah where kodepropinsi='" + kodePropinsi + "' and kodekabupaten='" + kodeKabupaten + "' group by namakabupaten";
          string namaKabupaten;
          using (NpgsqlCommand command = new NpgsqlCommand(this.query, this.conn))
          {
              using (NpgsqlDataReader dr = command.ExecuteReader())
              {
                  while (dr.Read())
                  {
                      namaKabupaten = dr["namakabupaten"].ToString();
                      return namaKabupaten;
                  }
              }
          }
          return string.Empty;         
      }
  </code></pre>
  
  <p>}</p>
  
  <p>and this is how I get connection</p>
  
  <pre><code>public class ConnectionService
  {
      public static NpgsqlConnection GetConnection()
      {
          string connStr = WebConfigurationManager.ConnectionStrings["local"].ConnectionString;
          NpgsqlConnection conn = new NpgsqlConnection(connStr);            
          conn.Open();
          return conn;
      }
  }
  </code></pre>
  
  <p>I didn`t write something like conn.close();
  but I was wrote conn.Open in using.</p>
  
  <p>For temporary I have changed max_connections = 100 to 1000 in postgresql.conf</p>
  
  <p>can you give me hint?</p>
  
  <p>Thanks in Advance</p>