private void btnBackup_Click(object sender, EventArgs e)
{
Backup bkp = new Backup();
this.Cursor = Cursors.WaitCursor;
this.dataGridView1.DataSource = string.Empty;
try
{
string fileName = this.txtFileName.Text;
string databaseName = this.ddlDatabase.SelectedItem.ToString();
bkp.Action = BackupActionType.Database;
bkp.Database = databaseName;
bkp.Devices.AddDevice(fileName, DeviceType.File);
bkp.Incremental = chkIncremental.Checked;
this.progressBar1.Value = 0;
this.progressBar1.Maximum = 100;
this.progressBar1.Value = 10;
bkp.PercentCompleteNotification = 10;
bkp.PercentComplete += new PercentCompleteEventHandler(ProgressEventHandler);
bkp.SqlBackup(srv);
MessageBox.Show("Database was successfully backed up to: " + fileName, "Info");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
this.Cursor = Cursors.Default;
this.progressBar1.Value = 0;
}
}
tnx im in andvance im in rush!!