我在用C#编写的连接云数据库MYSQL时总是报错如下
“System.Collections.Generic.KeyNotFoundException”类型的未经处理的异常在 mscorlib.dll 中发生 其他信息: 给定关键字不在字典中。C#代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Collections;
using System.Configuration;namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
            string sqlcon = @"server=57f2210a3f64d.sh.cdb.myqcloud.com;user id=cdb_outerroot;password=123456abc;database=test1;port=4916;charset=utf8mb4;pooling=true";
            string sql = @"
                    select
                        *
                    from
                        user
                    where
                        userid='1'";
            using (MySqlConnection conn = new MySqlConnection(sqlcon))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                MySqlDataReader dr = cmd.ExecuteReader();
                //将结果赋值到了dr,下面开始输出                    
                dr.Read();
                textBox1.Text = dr["userid"].ToString();
                textBox2.Text = dr["username"].ToString();
            }
        }  
    }
}这个问题困扰了我好几天了,希望各位大牛们不吝赐教,谢谢大家!