Exemplo n.º 1
0
        private void bRestore_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            wrSettings.wrSettings stg = new wrSettings.wrSettings();
            string         file       = null;
            OpenFileDialog sfd        = new OpenFileDialog()
            {
                Filter = "Backup File (*.sql)|*.sql|All Files (*.*)|*.*"
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                //File.Copy(sfd.FileName, Application.StartupPath + "/ims.mdb", true);
                file = sfd.FileName;
            }
            //string constring = stg.ConnString();
            //string file = "C:\\backup.sql";
            //using (MySqlConnection conn = new MySqlConnection(constring))
            //{
            //    using (MySqlCommand cmd = new MySqlCommand())
            //    {
            //        //using (MySqlBackup mb = new MySqlBackup(cmd))
            //        //{
            //        //    cmd.Connection = conn;
            //        //    conn.Open();
            //        //    mb.ImportFromFile(file);
            //        //    conn.Close();
            //        //}
            //    }
            //}
        }
Exemplo n.º 2
0
        private void bbAckup_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            string file             = null;
            string constring        = null;

            fbd.RootFolder = System.Environment.SpecialFolder.Desktop;
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                file = fbd.SelectedPath + "\\DB_BACKUP_" + DateTime.Now.Day.ToString("00") + DateTime.Now.Month.ToString("00") + DateTime.Now.Year.ToString() + ".sql";
            }
            wrSettings.wrSettings stg = new wrSettings.wrSettings();
            //constring = stg.ConnString();

            using (MySqlConnection conn = new MySqlConnection(constring))
            {
                using (MySqlCommand cmd = new MySqlCommand())
                {
                    //using (MySqlBackup mb = new MySqlBackup(cmd))
                    //{
                    //    cmd.Connection = conn;
                    //    conn.Open();
                    //    mb.ExportToFile(file);
                    //    conn.Close();
                    //}
                }
            }
        }