SqlConnection sqlCon = new SqlConnection(@"YOURCONNECTIONSTRING");
string database = sqlCon.Database.ToString();
try
{
string cmd = "BACKUP DATABASE [" + database + "] TO DISK='" + textBox1.Text + "\\" + "database" + "-" + DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".bak'";
using(SqlCommand command = new SqlCommand(cmd,sqlCon))
{
if(sqlCon.State!=ConnectionState.Open)
{
sqlCon.Open();
}
command.ExecuteNonQuery();
sqlCon.Close();
MessageBox.Show("database backup done successefully");
BackupButton.Enabled = false;
}
}
catch
{
}
My Name Is Salman Masood , I am Computer Science &Amp; Maths Graduate from University of Karachi, Pakistan , Teaching Is My Passion and My Aim Is to Deliver All My Knowledge among Those Students Who Can'T Afford Tutors or Expensive Institute Fees. I Will Be Keep Sharing My All Knowledge and Information with You .... Remember Me in Your Prayers !
Subscribe to:
Posts (Atom)
Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
