BKI_DichVuMatDat.HeThong.frm_backup_restore.RestoreDataBase C# (CSharp) Method

RestoreDataBase() private method

private RestoreDataBase ( string BackupFilePath, string destinationDatabaseName ) : void
BackupFilePath string
destinationDatabaseName string
return void
        private void RestoreDataBase(string BackupFilePath,
            string destinationDatabaseName)
        {
            SplashScreenManager.ShowForm(typeof(F_wait_form));
            try
            {
                Server myServer = GetServer();
                //Restore myRestore = new Restore();
                //myRestore.Database = destinationDatabaseName;
                //Database currentDb = myServer.Databases[destinationDatabaseName];
                //if(currentDb != null)
                //    myServer.KillAllProcesses(destinationDatabaseName);
                //myRestore.Devices.AddDevice(BackupFilePath, DeviceType.File);
                //string DataFileLocation = DatabaseFolder + "\\" + destinationDatabaseName + ".mdf";
                //string LogFileLocation = DatabaseFolder + "\\" + destinationDatabaseName + "_log.ldf";
                //myRestore.RelocateFiles.Add(new RelocateFile(DatabaseFileName, DataFileLocation));
                //myRestore.RelocateFiles.Add(new RelocateFile(DatabaseLogFileName, LogFileLocation));
                //myRestore.ReplaceDatabase = true;
                //myRestore.PercentCompleteNotification = 10;
                //myRestore.SqlRestore(myServer);
                //currentDb = myServer.Databases[destinationDatabaseName];
                //currentDb.SetOnline();

                Restore rstDatabase = new Restore();
                rstDatabase.Action = RestoreActionType.Database;
                rstDatabase.Database = destinationDatabaseName;
                myServer.KillAllProcesses(destinationDatabaseName);
                BackupDeviceItem bkpDevice = new BackupDeviceItem(BackupFilePath, DeviceType.File);
                rstDatabase.Devices.Add(bkpDevice);
                rstDatabase.ReplaceDatabase = true;
                rstDatabase.SqlRestore(myServer);

            }
            catch(Exception)
            {
                throw;
            }

            finally
            {
                SplashScreenManager.CloseForm();
            }
        }