C Sharp And Ms Access Database Tutorial 8 How To Delete Selected Rows From Datagridview And Microsoft Access Database
C# And Ms Access Database Tutorial #8 – How To Delete Selected Rows From Datagridview And Microsoft Access Database
VIDEO TUTORIAL
This Tutorial Shows How To Delete Selected Rows From Datagridview And Microsoft Access Database In C# Windows Forms Application using visual studio 2010.

C# SOURCE CODE
// Deleting Data From Microsoft Access Database private void btnDelete_Click(object sender, EventArgs e) { try { //check If Id TextBox Is Empty if (String.IsNullOrEmpty(txtID.Text)) { MessageBox.Show("ID Field Is Empty Click On Datagrid row cell first.........."); } else { OleDbCommand deleteDataFromMicrosoftAccessDatabaseQueryOleDbCommand = new OleDbCommand(DeleteDataFromMicrosoftAccessDatabaseQuery, microsoftAccessDatabaseOleDbConnection); deleteDataFromMicrosoftAccessDatabaseQueryOleDbCommand.Parameters.AddWithValue("ID", OleDbType.Integer).Value = Convert.ToInt16(txtID.Text); //Open Microsoft Access Database Connection openConnection(); int deleteDataFromMicrosoftAccessDatabase = deleteDataFromMicrosoftAccessDatabaseQueryOleDbCommand.ExecuteNonQuery(); if (deleteDataFromMicrosoftAccessDatabase > 0) { MessageBox.Show("Data Deleted From Microsoft Access Database Successfully........."); //Clear Input Fields clearInputFields(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //Close Microsoft Access Database Connection closeConnection(); //Refresh Datagridview after Deleting data From the database populateDataGridViewFromMicrosoftAccessDatabase(); } }