Question

I'm making library system management, and I have 3 tables in one dataset. I made add, edit and remove buttons to add, edit and remove data from tables (plus rent and return buttons).

When I restart vs2012 data is still there, but when I restart computer, data is gone.

Even that BindingNavigator that gets added when I added the first table, can't save data permanently. So only way to permanently manage data is by selecting table in Sever Explorer, than clicking on Show Table Data, and go through data without debugging or processing any code. That data reapers after restarting computer, weather I deleted it later by delete button or not.

Here's the code: This first one is save button for available books, and that code came with the first table I added, I didn't edit it at all.

 private void slobodne_KnjigeBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.slobodne_KnjigeBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.slobodneKnjigeDataSet);

        }

This second one is add button for new member to be added in members table.

private void button1_Click(object sender, EventArgs e)
        {
            this.članoviBindingSource.AddNew();
        }

Third one is save button for members table.

 private void button2_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.članoviBindingSource.EndEdit();
            this.tableAdapterManager2.UpdateAll(this.clanoviDataSet);
        }

This forth one is remove for members.

  private void button3_Click(object sender, EventArgs e)
        {
            if (this.članoviDataGridView.SelectedRows.Count > 0)
            {
                this.članoviBindingSource.RemoveCurrent();
            }


        }  

I know people often ask this question, I tried all the suggestions, but I couldn't fix it.

Was it helpful?

Solution

You have to call dataset.AcceptChanges() to commit the changes to the database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top