How to get SQL Server backup using C#

 Below code will take backup from sql server into your hard disk


public void backup_db()
   SqlConnection con = new SqlConnection("Your Connection");
   string SQL_Query = "BACKUP DATABASE billing_new TO DISK = 'D:db_name" + DateTime.Now.ToString("dd-MM-yyy mm ss") + ".Bak' WITH       FORMAT,MEDIANAME = 'theadal_backup',NAME = 'theadal_db backup';";
   SqlCommand cmd = new SqlCommand(SQL_Query, con);
   MessageBox.Show("Backup Successfull");

Note : MessageBox.Show wont work on web form unless you added winform dll to your project

if any query leave your comment below


happy coding :) 

Anto Sujesh Oct 20, 2017, 2:05 am


No Discussions Found

Article Discussions

Please login to your account to leave a comments