积极答复者
【求助】dataGridView连接mysql数据库不能更新

问题
-
代码如下,点击button后,dataGridView不能更新,求助
public partial class Form1 : Form { MySqlDataAdapter daCountry; DataSet dsCountry; private void Form1_Load(object sender, EventArgs e) { string myConnectionString; myConnectionString = "server=127.0.0.1;uid=root;pwd=123456;database=db1;"; MySqlConnection conn = new MySqlConnection(myConnectionString); try { string sql = "SELECT process, fileDir FROM file WHERE clientName='SIYUAN'"; daCountry = new MySqlDataAdapter(sql, conn); MySqlCommandBuilder cb = new MySqlCommandBuilder(daCountry); dsCountry = new DataSet(); daCountry.Fill(dsCountry, "file"); dataGridView1.DataSource = dsCountry; dataGridView1.DataMember = "file"; } catch (Exception ex) { label1.Text = ex.ToString(); } } private void button1_Click(object sender, EventArgs e) { daCountry.Update(dsCountry, "file"); } }
答案
-
重新绑定datagridview
http://feiyun0112.cnblogs.com/- 已标记为答案 BoberSongModerator 2010年8月18日 6:29
全部回复
-
重新绑定datagridview
http://feiyun0112.cnblogs.com/- 已标记为答案 BoberSongModerator 2010年8月18日 6:29