主题:不明白用BindingContext对数据项进行监控更新怎么会出错
构造函数里面,启动窗口的时候代码是这样
cmOrders = (CurrencyManager)BindingContext[person1, "person"];
cmOrders.AddNew();
我的窗口上面全是textbox单源绑定,属性里面已经添加了绑定,
然后我点确定更新
cmOrders.EndCurrentEdit();
if (person1.GetChanges() != null)
{
try
{ //SqlDataAdapter
personTableAdapter1.Update(person1);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
person1.RejectChanges();
}
}
更新总是出错,好像似乎要我对所有的textbox都进行填值一样,
怎么样可以对数据库里德非null字段不填值也能保证更新不报错?
cmOrders = (CurrencyManager)BindingContext[person1, "person"];
cmOrders.AddNew();
我的窗口上面全是textbox单源绑定,属性里面已经添加了绑定,
然后我点确定更新
cmOrders.EndCurrentEdit();
if (person1.GetChanges() != null)
{
try
{ //SqlDataAdapter
personTableAdapter1.Update(person1);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
person1.RejectChanges();
}
}
更新总是出错,好像似乎要我对所有的textbox都进行填值一样,
怎么样可以对数据库里德非null字段不填值也能保证更新不报错?