C# MySql.Data.dll 读取mysql 下载

        private void button1_Click(object sender, EventArgs e)
        {
            string str = "Data Source=.;User ID=root;Password=********;DataBase=otcms;charset=utf8;"; ;
            MySqlConnection conn = new MySqlConnection(str);

            conn.Open();

            MySqlCommand co = new MySqlCommand("select IF_source from it_info;", conn);


            MySqlDataReader re = co.ExecuteReader();
            if (re.HasRows)
            {
                while (re.Read())
                {
                    listBox1.Items.Add(re[0].ToString().Trim());


                }
            }



        }

winform代码
桂ICP备16004754号