Pages

Thursday, September 27, 2012

how to create ms access BACKUP and RESTORE in c#

http://stackoverflow.com/questions/5337040/create-a-backup-database-with-c-sharp

http://www.c-sharpcorner.com/Forums/Thread/64896/

http://www.daniweb.com/software-development/csharp/threads/202843/take-backup-of-sql-server-database-using-c

http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/4fbdec33-76d3-4e1e-bb33-6427a76665de/

http://vinothnat.blogspot.in/2009/01/how-to-taking-backup-database-using-c.html

http://www.dotnetobject.com/Thread-Mysql-backup-using-c

private void btnBackUp_Click(object sender, EventArgs e)
        {
            string CurrentDatabasePath =Environment.CurrentDirectory + @"\Database3.accdb";
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                string PathtobackUp = fbd.SelectedPath.ToString();
               File.Copy(CurrentDatabasePath,PathtobackUp+@"\BackUp.accdb",true);
                MessageBox.Show("Back Up SuccessFull! ");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {

            string PathToRestoreDB = Environment.CurrentDirectory + @"\Database3.accdb";
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string Filetorestore = ofd.FileName;

                // Rename Current Database to .Bak

                File.Move(PathToRestoreDB, PathToRestoreDB +".bak");

                //Restore the Databse From Backup Folder
                File.Copy(Filetorestore, PathToRestoreDB,true);

            }
        }

1 comment: