从asp .net页面下载数据库的备份 [英] download the back up of the database from an asp .net page

查看:72
本文介绍了从asp .net页面下载数据库的备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个三层asp .net,其中我的dal是使用dbcommand对象实现的.
我的问题是我想允许管理员将应用程序的远程数据库的脚本下载到其本地计算机上.
问题的解决方法是通过在我的SQL SERVER MANAGEMENT STUDIO中测试sql命令,它不起作用
这是我执行的命令

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

BACKUP DATABASE OFPPT 
TO DISK = 'Z:\back.bak'; 
GO



-其中Z:\是用户从模式弹出式窗口中指定的文件夹,该弹出式窗口在单击我的asp .net页面中的链接后显示.
我的目的是允许系统管理员从asp .net下载数据库的脚本.另一方面,当管理员单击链接下载数据库脚本"时,将弹出一个对话框提示您选择要下载脚本的目录,然后将数据库下载到所选目录中.



--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.

推荐答案

尝试一下.
1.执行T-SQL命令
Try this.
1. Execute the T-SQL command
BACKUP DATABASE <DatabaseName> TO DISK = "D:\Database.bak"


注意:这里的"D:\"是数据库服务器上的驱动器.如果数据库和Web服务器是两台不同的计算机,则在执行上述T-SQL命令后,将文件复制到Web服务器.
2.在您的网页上提供超链接,并将href设置为文件.


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.


这篇关于从asp .net页面下载数据库的备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆