string dbName="abc"; SqlConnection con = new SqlConnection(cnString1); string DestDir = @"C:\DatabaseBackup"; if (!System.IO.Directory.Exists(DestDir)) { System.IO.Directory.CreateDirectory(@"C:\DatabaseBackup"); } try { con.Open(); SqlCommand cmd = new SqlCommand("BACKUP DATABASE " + dbName + " TO DISK='" + DestDir + "\\" + dbName + ".bak' WITH FORMAT", con); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Database Backup Created 'C:\\DatabaseBackup\' drive and folder ");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)