1.将MySql.Data.dll引用到你的项目中
右键工程去完成。
2.using MySql.Data;
using MySql.Data.MySqlClient;
3.
1 MySqlConnection objConn = new MySqlConnection(); 2 objConn.ConnectionString = "Database='main_db';Data Source='localhost';User Id='root';Password='root';charset='utf8';pooling=true"; 3 objConn.Open(); 4 MySqlCommand objCmd = new MySqlCommand("select * from `main_db`.`t_user`", objConn); 5 MySqlDataReader r = objCmd.ExecuteReader(); 6 while (r.Read()) 7 { 8 9 textBox3.Text = textBox3.Text + r.GetString(0)+r.GetString(1); 10 11 } 12 objConn.Close();
测试OK