Populating, Restore and Backup SQL Database using C#

by Prashant 28. May 2009 00:01

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)

 


If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: ,

C#

Comments (5) -

Hassan
Hassan India
7/15/2011 11: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.

Reply

prashant
prashant India
7/16/2011 5:18:19 AM #

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.

Reply

Hassan
Hassan India
7/16/2011 6:02:59 AM #

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

Reply

prashant
prashant India
7/17/2011 5:04:30 AM #

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.

Reply

saleh
saleh Iran
8/6/2011 12:54:58 AM #

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

Reply

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Visit blogadda.com to discover Indian blogs Computers Blogs

About Me

Name of authorPrashant Khandelwal.
Programmer and tech enthusiast. More...

Feeds Subscribe Twitter Facebook Google Plus Linked In Delicious

My Visual Studio Achievements

Badges

Month List

Blog Stats

321,879 Hits

Adverts

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012

Creative Commons License