Hi
What is wrong in my this backup code it always not working and gives me an error
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;
AttachDbFilename=D:\repos\mysales\WindowsFormsApp4\Database1.mdf;
Integrated Security=True;
");
string database = con.Database.ToString();
if (textBox1.Text == "")
{
MessageBox.Show("Please Enter Backup File Location");
}
else
{
string cmd = "BACKUP DATABASE [" + database +"] To DISK = '"+ textBox1 .Text + " \\ " +"database"+"-"+ DateTime .Now .ToString ("yyyy-MM-dd--HH-mm-ss") +".bak'";
con.Open();
SqlCommand command=new SqlCommand(cmd, con);
command.ExecuteNonQuery();
MessageBox.Show("Database Backup Done Seccessfully.");
con.Close();
button2.Enabled = false;
}