Hi,
I have a database (OLEDB) on which i perform operations like insert, delete and update. When i carry out these operations, the changes are reflected in the database during runtime but when i close the form everything goes back to normal. How can i get these modifications to relfect in the datadase even after i close the form.

Thank you.

I would suggest posting the code. There has to be a problem either in the update or elsewhere in the coding.

Here's the code for doing an update

 private void updbtn_Click(object sender, EventArgs e)
        {
            string gen = "";
            if (male_rdbtn.Checked)
                gen = "M";
            if (female_rdbtn.Checked)
                gen = "F";
            //Updates the database
            OleDbDataAdapter da = new OleDbDataAdapter();

            da.UpdateCommand = new OleDbCommand();
            da.UpdateCommand.Connection = GetConnection();
            da.UpdateCommand.CommandText =
               "UPDATE patients SET " +
               "firstlastname ='" + nametxt.Text +
               "', birthdate='" + birthtxt.Text +
               "', birthplace='" + birthcmb.SelectedItem +
               "', gender='" + gen +
               "', bloodtype='" + bloodcmb.SelectedItem +
               "', telnum='" + teltxt.Text +
               "', address='" + addresstxt.Text +
               "' WHERE patientid=" + txt;

            da.UpdateCommand.ExecuteNonQuery();
            }

I used a same concepts for delete and insertion. OR would u need the entire code? Thanks

A database will store it's data until you delete it or do something else with it...it does not just delete itself when you close your application, it stays there.

Somewhere you must be doing something like overwriting the old table(s) or deleting the contents of your db when you load your app back up...

@james6754 i understand what you're saying but most of my tables are created when the form is loaded. so when i load the form again everything is re-created. Is there anything i can do to fix this?

This article has been dead for over six months. Start a new discussion instead.