How to restore the backup made with SMO?

0

I need to back up and restore using SMO. The backup I can do now, when I select it in the combobox by typing the server name and the error database. Here is the code for the restore button:

   private void restauracaoButton_Click(object sender, EventArgs e)
        {
            var server = new Microsoft.SqlServer.Management.Smo.Server(servidorTextBox.Text);
            var restore = new Microsoft.SqlServer.Management.Smo.Restore();
            restore.Database = databaseTextBox.Text;
            restore.Devices.AddDevice(backupsComboBox.SelectedValue.ToString(), Microsoft.SqlServer.Management.Smo.DeviceType.File);
            server.KillAllProcesses(databaseTextBox.Text);
            restore.SqlRestore(server);
            MessageBox.Show(string.Format("Backup '{0}' restaurado com sucesso.", backupsComboBox.Text), "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

Iwillposttheerrorprint

    
asked by anonymous 04.01.2016 / 15:23

0 answers