Whats wrong the code
string database = con.Database.ToString();
try
{
if(textBox1.Text==string.Empty)
{
MessageBox.Show("Enter your backup file location");
}
else
{
string cmd = "BACKUP DATABASE[" + database + "] TO DISK '" + textBox1.Text + "\\" + "Database" + "-" + DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".back'";
using(SqlCommand cmd2=new SqlCommand(cmd,con))
{
if(con.State!=ConnectionState.Open)
{
con.Open();
}
cmd2.ExecuteNonQuery();
con.Close();
MessageBox.Show("Database Backup Successfully");
btnBackup.Enabled = false;
}
}
}
catch
{
}