This tutorial about, taking a backup of the sql server database.
Following sql query, we can get a backup:
backup database database_name to disk='d:\aaa.bak'
To implement this backup in windows application.
- using (SqlConnection con = new SqlConnection(connectionstring))
- {
- con.Open();
- query = "backup database databasename to disk ='" + path + ""
- +System.DateTime.Now.Month+System.DateTime.Now.Date.ToString("dd")+System.DateTime.Now.Year+".bak'";
- using( SqlCommand cmd=new SqlCommand(query,con))
- {
- cmd.ExecuteNonQuery();
- MessageBox.Show("Saved successfully", "Backup", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- }
-
- }