Backup/Restore SQL database using C#

21. June 2009 15:59

C# SQL Server Utils  Comments

Microsoft’s .NET framework provides the flexibility to Backup and Restore SQL server database. A few lines to populate the names of all the server instances, create backups and then restore the backups. The application what you see here is a part of an application, so when you create backups and restore it will use the same path hardcoded in the code itself. You can change the way you like it.


Namespace you need to add:  

using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.IO;

I am not going to write on and on and just make it going boring, so it's better just download the code and check the comments, they are one liners, but clears everything. 

Download Full Application Here: DBBackup.zip (290.99 kb)

Currently rated 3.8 by 17 people