在工具栏弄个点击按钮更新datagridview时出现问题
何以笙箫 2010-12-29 10:37:32 补充下:我用的是sqldataadapter的update更新的 具体看下面代码(工具栏弄个点击按钮的click代码):
private void toolStripButton8_Click_1(object sender, EventArgs e)
{
cb = new SqlCommandBuilder(sda);
sda.UpdateCommand = cb.GetUpdateCommand();
this.BindingContext[ds.Tables[0]].EndCurrentEdit();
if (sda.Update(ds.Tables[0]) > 0)
{
MessageBox.Show("数据已更新!");
// dataGridView1.DataSource = ds.Tables[0];
}
else
{
MessageBox.Show("n");
}
}
项目的的字段为:
SqlConnection conn;
SqlDataAdapter sda;
DataSet ds;
SqlCommandBuilder cb = null;