protected void btnbackup_Click(object sender, EventArgs e) { sqlcon.ConnectionString = (System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString()); string destdir = "C:\\backupdb"; if (!System.IO.Directory.Exists(destdir)) { System.IO.Directory.CreateDirectory("C:\\backupdb"); } try { sqlcon.Open(); sqlcmd = new SqlCommand("backup database UsersDB to disk='" + destdir + "\\" + DateTime.Now.ToString("ddMMyyyy_HHmmss") + ".Bak'", sqlcon); sqlcmd.ExecuteNonQuery(); Response.Write("Backup database successfully"); } catch (Exception ex) { Response.Write("Error During backup database!"); } }
protected void btnrestore_Click(object sender, EventArgs e) { //try //{ sqlcon.ConnectionString = (System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString()); sqlcon.Open(); string destdir = "C:\\backupdb\\11082014_121403.Bak"; sqlcmd = new SqlCommand("Restore database UsersDB from disk='C:11082014_143650.Bak' ", sqlcon); sqlcmd.ExecuteNonQuery(); Response.Write("restore database successfully"); //} //catch (Exception ex) //{ // Response.Write("Error During backup database!"); //} }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)