Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# SQL Server Express backup and restore

Basically I have a windows form C# program that uses a SQL Server Express database to store data entered by the users. I want to add the ability for the user to be able to backup their database and then load a backup or another database into the programs database.

If someone could point me in the right direction like an article or tutorial that would be great, because I have hit a dead end.

Thanks

like image 811
sharkman Avatar asked Jul 22 '26 14:07

sharkman


2 Answers

You have a few options to do this:

  1. On the server directly call BACKUP DATABASE, RESTORE DATABASE commands.

  2. Use SMO (SQL Server Management Objects) to perform the backup restore operations programatically. (Specifically this sample)

  3. Use some third party utility/library.

like image 116
Pop Catalin Avatar answered Jul 25 '26 05:07

Pop Catalin


You may want to look at using this suggestion:

http://codeasp.net/articles/sql-server/118/backup-your-database-using-an-sql-command-export-to-bak

like image 39
Travis J Avatar answered Jul 25 '26 04:07

Travis J



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!