Ejemplo n.º 1
0
 private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     cls.ClsConnect();
     bll.TaoThuMuc(Thumuc);
     try
     {
         if (txtPath.Text == "")
         {
             MessageBox.Show("Chưa chọn đường dẫn", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         else
         {
             string BackUpLocation = txtPath.Text.Trim();
             string DatabaseName   = CboDb.SelectedValue.ToString().Trim();
             string BackUpFileName = CboDb.SelectedValue.ToString().Trim() + dtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".bak";
             BackupDatabase(BackUpLocation, BackUpFileName, DatabaseName);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     cls.DongKetNoi();
 }
Ejemplo n.º 2
0
        //end

        //----------------------------------------------------------------
        public void BackUpDb(string fileName, string filePath)
        {
            string          sqlBackup = "BACKUP DATABASE [" + fileName + "] TO DISK='" + filePath + "'";
            ClsConnectLocal cnn       = new ClsConnectLocal();

            cnn.ClsConnect();
            cnn.UpdateDataText(sqlBackup);
            cnn.DongKetNoi();
        }
Ejemplo n.º 3
0
        public void RestoreDb(string fileName, string filePath)
        {
            string          sqlRestore = "Use master Restore Database [" + fileName + "] from DISK='" + filePath + "'";
            string          drop       = "drop database " + fileName;
            ClsConnectLocal cnn        = new ClsConnectLocal();

            cnn.ClsConnect();
            cnn.UpdateDataText(drop);
            cnn.UpdateDataText(sqlRestore);
            cnn.DongKetNoi();
        }