using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace 数据库访问控件示例 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //单击导航工具栏上的“保存”按钮时执行以下事件处理程序 private void 雇员BindingNavigatorSaveItem_Click_1(object sender, EventArgs e) { this.Validate(); //验证控件的值 this.雇员BindingSource.EndEdit(); //将挂起的更改应用于基础数据源 this.tableAdapterManager.UpdateAll(this.northwindDataSet);//保存所有数据表中的所有数据 } private void Form1_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“northwindDataSet.雇员”中。您可以根据需要移动或删除它。 //调用雇员TableAdapter的主方法来填充类型化数据集对象northwindDataSet的"雇员"表 this.雇员TableAdapter.Fill(this.northwindDataSet.雇员); } } } |