Need help with C# Save Button

Soli
by Soli · 3 posts
6 years ago in .Net (C#, VB, etc)
Posted 6 years ago · Author
I have a C# Windows App and I am trying to code up a Save Button. I have no errors in my code; however, my dataset is not saving changes. Any suggestions would be appreciated.

Code
        private void SaveButton_Click_1(object sender, EventArgs e)
        {
            try
            {
                         
                dataTable1BindingSource1.EndEdit();
               
                App.DataTable1.WriteXml(string.Format("{0}//data.dat", Application.StartupPath));
                               
                MessageBox.Show("Save Complete");
                groupBox3.Enabled = false;
                grpBxReportedBy.Enabled = false;
                groupBox1.Enabled = false;
                App.DataTable1.AcceptChanges();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Messages", MessageBoxButtons.OK, MessageBoxIcon.Error);
                App.DataTable1.RejectChanges();
            }
        }

       

        static DataSet1 db;
        protected static DataSet1 App
        {
            get
            {
                if (db == null)
                    db = new DataSet1();
                return db;
            }
        }

        private void FascilitiesMaint2018_Load(object sender, EventArgs e)
        {

            string fileName = string.Format("{0}//data.dat", Application.StartupPath);
            if (File.Exists(fileName))
            {
                App.DataTable1.ReadXml(fileName);

            }
           
            dataTable1BindingSource1.DataSource = App.DataTable1;
            groupBox3.Enabled = false;
            grpBxReportedBy.Enabled = false;
            groupBox1.Enabled = false;


        }


Thank you guys so much :vdaycat:
Posted 6 years ago · Author
Hi Don. Sorry, I havent been on i a while. I did figure out how to read and write to xml. App is completed, just adding the extras. I was just about to post a new topic on that :) ty for taking the time to answer.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT