Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a three tier asp .net where my dal is implemented using dbcommand object
my problem is i want to allow the administrator to download the script of the remote database of the application to their local machine
the problem encouter is by testing the sql command in my SQL SERVER MANAGEMENT STUDIO, IT DOESN't work
this the command i execute
SQL
BACKUP DATABASE OFPPT 
TO DISK = 'Z:\back.bak'; 
GO


--where Z:\ is a folder which the user specify from a modal popup which appears after clickin a link in my asp .net page.
my aim is to allow the administrator of the system to download the script of the database from an asp .net. in other hand when administrator will click a link "download db script" it will be prompted with a popup to select the directory in which it will download the script, next the database will be downloaded in the selected directory.
Posted
Comments
Karthik. A 26-Jun-12 15:53pm    
Check out this link for a couple of ways to create a backup using command line / a script. If you are looking for more inputs apart from the step of taking a backup, update your question.
Kiran Susarla 27-Jun-12 3:41am    
Are you saying the adminstrative user of your site should be able to backup a database and download it on his or her local machine?
elidrissi.amine1 27-Jun-12 4:08am    
yes, the administrator has the ability to download the back up file of the database to the local with which is displaying the asp .net page that contain a a link "download back up file of the database" which when clicked, it shows a popup to select the directory in which the back up file will be downloaded.

1 solution

Try this.
1. Execute the T-SQL command
SQL
BACKUP DATABASE <DatabaseName> TO DISK = "D:\Database.bak"

Note: Here "D:\" is the drive on your database server. If your database and webserver are two different machines, then after executing the above T-SQL command, copy the file to your webserver.
2. Provide the hyperlink on your web page and set the href to the file.
 
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