我拖动一个表worker 到form 中,会自动添加一些控件,dataset 等。
如图,“添加“按钮也会产生类似的代码。
问题是我的 一个主键是自增列,这样运行时保存,就报workerid 不能为空,怎么解决??
- C# code
private void workerBindingNavigatorSaveItem_Click_2(object sender, EventArgs e) { if (this.Validate()) { this.workerBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.workermanageDataSet); } else { MessageBox.Show(this, "验证错误", "保存失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
------解决方案--------------------
你看下你保存的是什么啊,表? 集合?
------解决方案--------------------
主键是自增列 那你的workerid 不是主键吧