代码似乎很好但是当我点击它时,没有任何反应。 谢谢!
private void button2_Click(object sender, EventArgs e)
{
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = new MySqlCommand("select * from poitems", coninsert);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds, "poitems");
da.Update(ds, "poitems");
//DataTable dt1 = new DataTable();
//da.Fill(dt1);
//da.Update(dt1);
//dtgPo.DataSource = dt1;
}
答案 0 :(得分:0)
您没有更新数据集中的任何内容,请查看以下示例更新代码
MySqlConnection conn = new MySqlConnection(connectionString);
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da, true);
DataTable dt = new DataTable();
da.Fill(dt);
//update datatable
dt.Rows[0][0] = "my changed value";
DataTable changes = dt.GetChanges();
//call update
da.Update(changes);
dt.AcceptChanges();