title: The given key was not present in the dictionary. with mysql
body: <p>I am trying to link a project in <strong>C#</strong> with <strong>MySQL</strong> (<strong><em>localhost</em></strong>)
  but i getting error while executing login</p>
  
  <pre><code>System.Collections.Generic.KeyNotFoundException was unhandled
  HResult=-2146232969
  Message=The given key was not present in the dictionary.
  Source=mscorlib
  StackTrace:
  at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
  at MySql.Data.MySqlClient.CharSetMap.GetCharacterSet(DBVersion version, String CharSetName)
  at MySql.Data.MySqlClient.NativeDriver.GetFieldMetaData41()
  at MySql.Data.MySqlClient.NativeDriver.GetFieldMetaData()
  at MySql.Data.MySqlClient.NativeDriver.ReadColumnMetadata(Int32 count)
  at MySql.Data.MySqlClient.ResultSet.LoadMetaData()
  at MySql.Data.MySqlClient.ResultSet.NextResult()
  at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
  at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
  at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
  at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
  at College_Student.login.button1_Click(Object sender, EventArgs e) in C:\Users\zMJ\Desktop\College_Student\College_Student\login.cs:line 87
  at System.Windows.Forms.Control.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnClick(EventArgs e)
  </code></pre>
  
  <p>this what i try  connection </p>
  
  <pre><code> MySqlConnection con = new MySqlConnection(" Server=localhost;Database=college_management;Uid=root;Pwd=12345678;CharSet=utf8;");
  </code></pre>
  
  <p>and using library </p>
  
  <pre><code>    using MySql.Data.MySqlClient;
  using System.Data;
  </code></pre>
  
  <p>and in button </p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      i=0;
      con.Open();
      MySqlCommand cmd = con.CreateCommand();
      cmd.CommandType = CommandType.Text;
      cmd.CommandText = "SELECT * FROM  admins where name='" + textBox1.Text + "' and password='" + textBox2.Text + "' ";
      cmd.ExecuteNonQuery();
      DataTable dt = new DataTable();
      MySqlDataAdapter da = new MySqlDataAdapter(cmd);
      da.Fill(dt);
      i = Convert.ToInt32(dt.Rows.Count.ToString());
  
      if (i == 0)
      {
          MessageBox.Show("error");
      }
      else
      {
          this.Hide();
          new home().Show();
  
      }
  
      con.Close();
              }
  </code></pre>