Hi ALL,
有以下代碼出錯了,同樣的代碼在另一表格中可就可執行,不明白問下各位。
- C# code
-
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace HY_New { public partial class frmProCla : Form { public frmProCla() { InitializeComponent(); } private void ChangeEnableState() { proClassTableBindingNavigator.Enabled = !proClassTableBindingNavigator.Enabled; gbEdit.Enabled = !gbEdit.Enabled; foreach (ToolStripButton b in tsControl.Items) { b.Enabled = !b.Enabled; } } private void frmProCla_Load(object sender, EventArgs e) { // TODO: 這行代碼将資料加載到表“_DsHY_new.Department”中。您可以根據需要移動或删除它。 this.departmentTableAdapter.Fill(this._DsHY_new.Department); // TODO: 這行代碼将資料加載到表“_DsHY_new.ProClassTable”中。您可以根據需要移動或删除它。 this.proClassTableTableAdapter.Fill(this._DsHY_new.ProClassTable); } private void tsbInsert_Click(object sender, EventArgs e) { ChangeEnableState(); proClassTableBindingSource.AddNew(); proClassNameTextBox.Focus(); } private void tsbEdit_Click(object sender, EventArgs e) { ChangeEnableState(); proClassNameTextBox.Focus(); } private void tsbDelete_Click(object sender, EventArgs e) { if (proClassTableBindingSource.Current != null) { if (MessageBox.Show("确實要删除嗎?", "确認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { proClassTableBindingSource.RemoveCurrent(); [color=#0000FF]this.tableAdapterManager.UpdateAll(this._DsHY_new);[/color] //此處出錯 } } } private void tsbSave_Click(object sender, EventArgs e) { ChangeEnableState(); this.Validate(); this.proClassTableBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this._DsHY_new); //此處在新增時儲存通過,在修改時儲存出錯。 } private void tsbCancel_Click(object sender, EventArgs e) { ChangeEnableState(); this.proClassTableBindingSource.CancelEdit(); } } }
http://topic.csdn.net/u/20120424/14/3e04e81f-2a28-4375-8e20-53b8d00e31e9.html