如何在C#中备份和恢复SQL数据库? [英] How to Backup and Restore SQL Database in C#?

查看:77
本文介绍了如何在C#中备份和恢复SQL数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows应用程序中只有一个sql数据库。请帮助我如何备份并恢复它。

谢谢。

I have only one sql database in my Windows Application. Please help me how can i take backup it & restore it.
Thank You.

推荐答案

阅读这篇文章 -



C#中的SQL Server数据库备份和恢复 [ ^ ]





-

RD Burmon


希望这有帮助,如果是,然后接受并投票我的答案
Read this article -

SQL Server Database Backup and Restore in C#[^]


--
RD Burmon

Hope this helps if yes then accept and vote my answer


最简单的方法是使用T-SQL命令BACKUP [ ^ ]和恢复 [< a href =https://msdn.microsoft.com/en-us/library/ms186858.aspxtarget =_ blanktitle =New Window> ^ ] whic h您将通过 SqlCommand -object与 ExecuteNonQuery()一起发布任何其他非查询语句(例如INSERT或CREATE TABLE)。



例如,最基本的备份命令看起来与此类似:

The simplest way is to use the T-SQL commands BACKUP[^] and RESTORE[^] which you would issue through an SqlCommand-object with ExecuteNonQuery() like any other non-query-statement (e.g. INSERT or CREATE TABLE).

For example, the most basic backup-command would look similar to this:
BACKUP DATABASE myDatabaseName TO DISK = 'C:\somewhere\myDatabaseName.bak';





除了上面链接的MSDN文档:



备份命令的一些示例:

http://www.mssqltips.com/sqlservertutorial/20/sql-server-backup-database-command/ [ ^ ]



如何创建备份 - 或通过SQL-Server Management Studio恢复命令(你可以使用它)然后复制到您的应用程序中):

http://www.sqlteam.com/article/backup-and-restore-in-sql-server-full-backups [ ^ ]


1.如果你是查看C#中的代码,然后按照网址:

http://manish4dotnet.blogspot。 in / 2013/03 / DatabaseBackupusingCSharp.html [ ^ ]



2.)通过界面跟随:

http://www.c-sharpcorner.com/Blogs/8679/backup-and-还原最数据库中-ASP-的Net-web应用程序lication.aspx [ ^ ]



希望这对您有所帮助!
1.) If you are looking through code in C# then follow the url:
http://manish4dotnet.blogspot.in/2013/03/DatabaseBackupusingCSharp.html[^]

2.) Through interface follow:
http://www.c-sharpcorner.com/Blogs/8679/backup-and-restore-the-database-in-Asp-Net-web-application.aspx[^]

Hope this helps to you!


这篇关于如何在C#中备份和恢复SQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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