Amresh Kushwaha
Total Post:37
Points:259
How to take backup of sel server 2005
Total Post:37
Points:259Post:37
Points:259
I want to command
Post:126
Points:882
Write down following code snippet in c# to take backup. One thing remeber that creadential should be changed..
using System; using System.Data; using System.Collections;
using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Smo;
class Program { static void Main(string[] args) { BackupDeviceItem bdi = new BackupDeviceItem("AdventureWorks.bak", DeviceType.File);
Backup bu = new Backup( ); bu.Database = "AdventureWorks"; bu.Devices.Add(bdi); bu.Initialize = true;
// add percent complete and complete event handlers bu.PercentComplete += new PercentCompleteEventHandler(Backup_PercentComplete); bu.Complete +=new ServerMessageEventHandler(Backup_Complete);
Server server = new Server("localhost"); bu.SqlBackup(server);
Console.WriteLine(Environment.NewLine + "Press any key to continue."); Console.ReadKey( ); }
protected static void Backup_PercentComplete( object sender, PercentCompleteEventArgs e) { Console.WriteLine(e.Percent + "% processed."); }
protected static void Backup_Complete(object sender, ServerMessageEventArgs e) { Console.WriteLine(Environment.NewLine + e.ToString( )); } }
Post:37
Points:259Thanku Awadhendra Tiwari
Sir Your Database Backup Code is Very Helpful
© Copyright © 2010 - 2019 MindStick Software Pvt. Ltd. All Rights Reserved
Post:127
Points:915Re: Data Backup
In Management Studio select database >> right click on selected database >> tasks >> back up