Visual Studio 2010中基于服务的数据库 [英] Service-based Database in visual studio 2010

查看:144
本文介绍了Visual Studio 2010中基于服务的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello开发人员,

实际上我的问题是,我在c#中使用基于服务的数据库创建了一个项目。一切都很顺利。但我坚持备份和恢复过程。

我已经完成了备份,我得到了databasename.bak文件但我不知道如何在基于服务的数据库中恢复该BAK文件。

如果可能的话请告诉我这是可能的,如果是的话请告诉我该怎么做。是否有任何第三方软件我必须使用或由Code完成。

解决方案

我不是这个领域的专家,但我相当肯定问题是你正在使用SQL-Express和Connectionstring-OptionAttachDBFileName。



请查看这些网站以获取更多信息:

attachdbfilename-option-in-connection-string [ ^ ]

sql-server-backuprestore [ ^ ]

how-to-backup-and-restore-sql-express-2005-attachdbfilename-mode [ ^ ]

connecting-to-sql-express-user -instances-in-management-studio.aspx [ ^ ]



来自第三个链接网站我提取了这个可能的解决方案:



1)对于恢复,从Connectionstring中删除AttachDBFileName-Part。



2)用于恢复命令:

  string  destinationDb =  <路径> \\Database1.mdf; 
string backupDb = < path> \\DBNameBackup.bak;
string query = USE [master] ; RESTORE DATABASE [ + destinationDb + ] FROM DISK = N' + backupDb + 'WITH REPLACE;;





如果这是您的问题的解决方案,请将此标记为已接受:-)

如果没有,请告诉我,我将尝试深入研究它。


Hello developers,
Actually my problem is, I made a project in c# with service-based Database. Everything is going good. But I am stuck with backup and Restore process.
I have done Backup and I got databasename.bak file But I don't know how to Restore that BAK file in service-based Database.
If possible please tell me that is it possible and if it is then please tell me how to do that. Is there any third-party software that I have to use or is it done by Code.

解决方案

I'm no expert in this field but I'm fairly certain that the problem is that you're using SQL-Express together with the Connectionstring-Option "AttachDBFileName".

Please have a look at these sites for further information:
attachdbfilename-option-in-connection-string[^]
sql-server-backuprestore[^]
how-to-backup-and-restore-sql-express-2005-attachdbfilename-mode[^]
connecting-to-sql-express-user-instances-in-management-studio.aspx[^]

From the third linked site I "extracted" this as a possible solution:

1) For the restore, remove the "AttachDBFileName"-Part from the Connectionstring.

2) Use this for the restore command:

string destinationDb = "<path>\\Database1.mdf";
string backupDb = "<path>\\DBNameBackup.bak";
string query = "USE [master]; RESTORE DATABASE [" + destinationDb + "] FROM DISK = N'" + backupDb + "' WITH REPLACE;";



If this is the solution for your problem, please mark this as accepted :-)
If not, please tell and I will try to dig deeper into it.


这篇关于Visual Studio 2010中基于服务的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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