Need help with C# Save Button

Soli
by Soli · 3 posts
5 years ago in .Net (C#, VB, etc)
Posted 5 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 5 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
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts