引用mysql.data.dll
连接语句中加入charset=utf8就好了
实例:
MySqlConnection mySqlC = new MySqlConnection("user id=root;password=ebdoor0044;host=localhost;database=scbhsw;charset=utf8");
MySqlCommand msqlCmd;
string strSql;
strSql = "insert into cd_news (cid,title,author,addTime,content,pic,clickNum) values (1,'我的标题','winne','1999-09-09','current','fsafsaf',33)";
msqlCmd = new MySqlCommand(strSql, mySqlC);
mySqlC.Open();
msqlCmd.ExecuteNonQuery();
msqlCmd = new MySqlCommand("select * from cd_news", mySqlC);
MySqlDataAdapter msqlAd = new MySqlDataAdapter(msqlCmd);
DataSet ds=new DataSet();
msqlAd.Fill(ds,"cd_news");
dataGridView1.DataSource=ds.Tables[0].DefaultView;
mySqlC.Close();