string database = con.Database.ToString(); try { if (textBox1.Text == string.Empty) { MessageBox.Show("Please Enter Path"); } else { string cmd = ("BACKUP DATABASE [" + database + "] TO DISK '" + textBox1.Text + "\\" + "Database" +"-"+ DateTime.Now.ToString("yyyy-MM-dd--HHmmss")+".bak'"); using (SqlCommand command = new SqlCommand(cmd, con)) { if (con.State != ConnectionState.Open) { con.Open(); } command.ExecuteNonQuery(); con.Close(); MessageBox.Show("Backup Completed Successfully"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)