使用.bak文件还原数据库 [英] Restore Database using.bak file

查看:278
本文介绍了使用.bak文件还原数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家晚上好,

请说出如何使用vb.net还原SQL Server数据库(.bak文件)?


我正在使用此代码..

Good Evening Everybody,

Please say how to restore a sql server database (.bak file) using vb.net?


And I am using this code ..

sqlsring = "use master RESTORE DATABASE DBNAME from disk=DBPathName"


但我收到此错误.

备份集保存除现有"DBNAME"数据库以外的数据库备份.
还原数据库异常终止.将数据库上下文更改为"master""

因此,请告诉我该错误的解决方案

谢谢.


But I am getting this error.

"The backup set holds a backup of database other than the existing ''DBNAME'' database.
Restore database is terminating abnormally. Changed database context to ''master''"

So Please tell me what is the solution for this error

Thank You.

推荐答案

尝试一下
RESTORE DATABASE DBNAME
FROM DISK = DBPathName+'\BackUpYourBaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO DBPathName+'\DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO DBPathName+'\DataYourLDFFile.ldf'


这篇关于使用.bak文件还原数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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