本帖最后由 shuke2003 于 2012-11-11 00:32:53 编辑

解决方案 »

  1.   


    我数据库中的id是自动加1,datagridview中的id是只读属性的。而且我在原记录上修改某个字段也保存不了
      

  2.   

    是不是mysql中的缓存导致的问题?
      

  3.   

    非常奇怪诡异的是我在保存前添加一行然后立刻再删除这行,保存就能成功。
    难道说update这个命令一定要bingsource执行一个动作才能触发吗?//保存按钮
    private void toolStripButton13_Click(object sender, EventArgs e)
    {
         MySqlCommandBuilder scb = new MySqlCommandBuilder(sda);
         try
         {
             bindingSource1.AddNew();
             bindingSource1.RemoveCurrent();
     
             sda.Update((System.Data.DataTable)bindingSource1.DataSource);
             MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             dataGridView1.Update();
          }
          catch (Exception ex)
          {
               MessageBox.Show(ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
    }
      

  4.   


    这个报错,如果我把sql语句里面AS后面的中文去掉,就不会报错。而且这个错也是时有时无的,哎