我使用BindingSource的AddNew()方法来新增记录,结果出错.代码如下:
// 工具栏中"保存"按钮的Click Event
private void tsbSave_Click(object sender, EventArgs e)
{
if (this.currentState == interfaceState.AddState)
{
this.bsEmployees.AddNew();
}
this.bsEmployees.EndEdit();
this.sdaEmployees.Update(this.dsHrm.Tables["Employees"]);
this.currentState = interfaceState.BrowseState;
this.controlsState(this.currentState);
}
// 用户在BindingSource上调用AddNew时引发的事件
private void bsEmployees_AddingNew(object sender, AddingNewEventArgs e)
{
Hashtable newRow = new Hashtable();
newRow["E_ID"] = this.tbE_ID.Text.Trim();
newRow["E_Name"] = this.tbE_Name.Text.Trim();
newRow["E_Code"] = this.tbE_Code.Text.Trim();
newRow["E_Gender"] = this.cbE_Gender.SelectedIndex.ToString();
newRow["E_Birthday"] = this.dtpE_Birthday.Value.ToShortDateString();
newRow["E_UID"] = this.tbE_UID.Text.Trim();
newRow["E_FSchool"] = this.tbE_FSchool.Text.Trim();
newRow["E_Speciality"] = this.tbE_Speciality.Text.Trim();
newRow["E_Address"] = this.tbE_Address.Text.Trim();
newRow["E_Guardian"] = this.tbE_Guardian.Text.Trim();
newRow["E_LinkTel"] = this.tbE_LinkTel.Text.Trim();
newRow["E_InFactory"] = this.dtpE_InFactory.Value.ToShortDateString();
e.NewObject = newRow;
}
错误信息: