我尝试使用 this.TableManager.UpdateAll 更新数据库。添加的第一个客户端很好,但是当我想添加一个新客户端时,我得到了重复键错误。这是代码:
//using a try command so if there is an exception, it will display it
try
{
//check if there are any changes prevents someone pressing save twice and you may get duplicate entries in database
if (this.allensCroftDataSet.HasChanges())
{
//It will then check if a row has been added:
if ((this.TableManager.UpdateAll(this.allensCroftDataSet) > 0))
{
//And it will then display a message box saying “saved”.
MessageBox.Show("Saved.");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}