Access Database Not Updating or Inserting or Deleting C# using Table Adapters and DataBinding

498 views Asked by At

I am trying to update my Access File Using Table Adapter . When i add the Data my DataGridview shows that data has been added or deleted But when I Check my access file it stays the same THere is no Compilation Error or No Excetion Error This is the Following Code This is the Image of the Data Grid View ....

  private void adminFlights_Load(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'appData.Airline' table. You can move, or remove it, as needed.
        this.airlineTableAdapter.Fill(this.appData.Airline);
        airlineBindingSource.DataSource = this.appData.Airline;

    }

 private void dataGridView2_KeyDown(object sender, KeyEventArgs e)
    {//TO delete data from Data Grid view
        if (e.KeyCode == Keys.Delete)
        {
            MessageBox.Show(e.KeyCode.ToString());
            if (MessageBox.Show("Are You Sure You want TO Delete ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                airlineBindingSource.RemoveCurrent();
             }}}




   private void btnSave_Click(object sender, EventArgs e)
    {//this the Button i am using save the Data into acess using DatagridView

        try
        {
            dataGridView2.DataSource = airlineBindingSource.DataSource;

            airlineBindingSource.EndEdit();
            airlineTableAdapter.Update(this.appData.Airline);

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
        }
    }


  private void Add_flights_Click(object sender, EventArgs e)
    {
        try
        {
            panel.Enabled = true;
            Airline_add.Focus();
            this.appData.Airline.AddAirlineRow(this.appData.Airline.NewAirlineRow());
            airlineBindingSource.MoveLast();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
            airlineBindingSource.ResetBindings(false);
        }
    }
0

There are 0 answers