// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"].ToString());
string sBackup = "BACKUP DATABASE " + myConnection.Database + " TO DISK = 'c:\\sql.bak' WITH NOINIT";
SqlCommand myCommand = new SqlCommand(sBackup, myConnection);
// Open the database connection and execute the command
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
return true;
http://expert.csdn.net/Expert/topicview.asp?id=1206543
Create a stored procedure to do the backup work.
Call the stored procedure from the program.
The following SP will backup the northwind database:
CREATE PROCEDURE [backup_database]
AS
declare @BackupFile varchar(100)
-- Directoryto store the backup file
select @BackupFile = 'c:\zx\northwind_db_' + Convert(varchar(10),Datepart(yy,getdate())) + right('00'+convert(varchar(10),Datepart(mm,getdate())),2) + right('00'+convert(varchar(10),Datepart(dd,getdate())),2) + '.dmp'