还原数据库时出错 [英] Error in restore database

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

问题描述

try
{
  gn.open();
  string str;
                
  str = @"RESTORE DATABASE bw FROM DISK = 'C:\SQLBackup\bw.bak'";
  SqlCommand cmd = new SqlCommand(str, gn.cn());
  cmd.ExecuteNonQuery();
}


我尝试了上述编码以使用Windows应用程序还原数据库.


i tried above coding to restore database using windows application ., i am getting error like.,

restore cannot process database 'bw' because it is in use by this session. it is recommended that the master database be used when performing this operation.
restore database is terminating abnormally

>

推荐答案

Umapathi,
为此的替代解决方案是创建另一个数据库并连接到该数据库,然后执行您的脚本.
对于前.如果要还原数据库TempDb而不是创建另一个数据库TempDB_Conn,那么当您要还原数据库时,请连接TempDB_Conn.

可能对您有帮助....
Hi Umapat
Alternate solution for this is create another database and connect on that database and then execute your script.
for ex. If You are going to restore database TempDb than create anothere database TempDB_Conn and when you want to restore db that time connect TempDB_Conn.

May be this help you....


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

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