Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
I want to create my whole database backup just on single button click and inside solution folder.After button click .bak file will be downloaded.

Note:-

I need C# code to backup database on button click event and inside solution folder or in any folder whatever i need as per requirement


Thank U.
Posted
Updated 30-Apr-19 2:33am
v2
Comments
virusstorm 30-Jul-15 13:21pm    
Are you trying to backup the database from within your solution, no applications running or by launching an application in the solution and click the button to backup the database?

One simple way is, using a SqlCommand, you execute a BACKUP[^] command.

After the backup is successfully created, copy the files created where you want.

Just make sure that
- you have sufficient privileges.
- the target folder is accessible by the credentials your program uses.
 
Share this answer
 
v2
Comments
itsathere 30-Jul-15 11:02am    
whatever u have written i think, it's sql command to backup database.
Wendelius 30-Jul-15 11:07am    
I'm sorry but I don't quite understand your reply. SqlCommand is the class in SqlClient namespace to execute commands in a SQL Server database.
SQL server can only
backup to a drive that is accessible to the server - if you issue a command to backup a database to a folder on the C: drive, it will try to back it up to the C: drive on the database server, NOT to the C: drive on the machine on which the application is running (unless you happen to be running the application on the database server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900