title: Can't connect to MySQL database due to KeyNotFoundException
body: <p>Not sure why I get an error every single time i try to connect. I tried so many things. When i type the wrong password while connecting manually it says access not granted or whatever so I know it connects but when it connects I get this weird error.</p>
  
  <blockquote>
    <p>An unhandled exception of type
    'System.Collections.Generic.KeyNotFoundException' occurred in
    mscorlib.dll Additional information: The given key was not present in
    the dictionary.</p>
  </blockquote>
  
  <p>For localhost it works when I have this connection string. </p>
  
  <pre><code>server=localhost; port=3306; USER ID=root; password=***; database=database;
  </code></pre>
  
  <p>but when I change the server user id and password it decides to not work.</p>
  
  <p>The exception is thrown at <code>cn.Open()</code>;</p>
  
  <pre><code>     private void button1_Click(object sender, EventArgs e)
      {
          MySqlConnection cn = new MySqlConnection();
          cn.ConnectionString = "server=db4free.net ;port=3306; 
                                 user=goof; password=pwd; database=s;";
          cn.Open();
          MySqlCommand cmd = new MySqlCommand("select * from users where
                                               username = '" 
                                               + textBox1.Text + "',
                                               and password = '" 
                                               + textBox2.Text + "'", cn);
          MySqlDataReader dr;
          dr = cmd.ExecuteReader();
          int count = 0;
  
          while(dr.Read())
          {
              count += 1;
          }
          if(count == 1)
          {
              MessageBox.Show("success");
          }
          else
          {
              MessageBox.Show("error");
          }
      }
  </code></pre>