<pre> public EmployeeForm() { this.bindingSource = new BindingSource(); this.Load += new EventHandler(EmployeeForm_Load); } private void EmployeeForm_FormClosing(object sender, FormClosingEventArgs e) { this.connection.Close(); this.connection.Dispose(); } private void RetrieveDataFromTheDatabase() { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"Employee.mdb\""; this.connection = new OleDbConnection(connectionString); this.connection.Open(); OleDbCommand command = connection.CreateCommand(); command.CommandText = "Select * From Employee"; this.adapter = new OleDbDataAdapter(); this.adapter.SelectCommand = command; this.dataset = new DataSet(); this.adapter.Fill(dataset, "Employee"); OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(this.adapter); commandBuilder.ConflictOption = ConflictOption.OverwriteChanges; commandBuilder.GetInsertCommand(); commandBuilder.GetDeleteCommand(); commandBuilder.GetUpdateCommand(); } private void BindControls() { this.bindingSource.DataSource = this.dataset.Tables[0]; this.dgvEmployee.DataSource = this.bindingSource; } void FileSave_Click(object sender, EventArgs e) { this.adapter.Update(this.dataset, "Employee"); this.dgvEmployee.EndEdit(); this.bindingSource.EndEdit(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)