Populating, Restore and Backup SQL Database using C#

27. May 2009 15:01

C#  5 Comments

You want to add a functionality in your C# application to allow user to select the database to restore and taking backups of the database. C# provides the classes to allow a programmer to achieve this in the application.


Before you go and implement this feature in your application, make sure you have added the references of the following namespaces:

1.) Microsoft.SqlServer.Smo

2.) Microsoft.SqlServer.ConnectionInfo


Click the below link to download the full application


Download: DBBackup.zip (290.99 kb)


Currently rated 4.0 by 1 person

Comments (5)

Hassan Hassan
7/15/2011 2:37:00 PM #

I'm looking for a tool for a simple back up and restore but i want it to be version and OS agnostic. a tiny windows app would do, but it should be able to backup and restore databases (2005 and 2008) and should run on xp, 2003 and 2008. we have written on such tool but the smo version is creating a conflict when we run on windows 2008 sever.

prashant prashant
7/15/2011 8:18:19 PM #

Version conflict will be a problem when communicating with different version of SQL server. Best option here is to set create a SQL agent job which take regular backups of your database. At our client side also we have used agent jobs to overcome the SMO issue.

Hassan Hassan
7/15/2011 9:02:59 PM #

thanks prashant. but we have a product shipped with backup restore tool and need a generic one :(

prashant prashant
7/16/2011 8:04:30 PM #

Well, for a product you can then have different versions for different SQL Server. But making generic with the use of SMO could be a problem as far as I can see this.

saleh saleh
8/5/2011 3:54:58 PM #

I hope this help me to finish my project. Thanks any more.

Add Comment

Visit blogadda.com to discover Indian blogs Computers Blogs