如何在C#中恢复数据库SQL 2008?
作者:互联网
我想在C#中恢复数据库,使用文件类型.BAK
var db = new QLTDEntities();
var con = ((SqlConnection)db.Database.Connection);
con.Open();
string stringquery = "RESTORE DATABASE TEST FROM DISK ='D:\ABC.BAK'";
SqlCommand cmd = new SqlCommand(stringquery, con);
cmd.ExecuteNonQuery();
con.Close();
我在第cmd.ExecuteNonQuery()行遇到错误;
'TEST' is not a recognized RESTORE option.
你能告诉我我的错误或错误的地方吗?
解决方法:
试试这样:
string stringquery = @"USE master BACKUP DATABASE [TEST] TO DISK='D:\ABC.BAK'";
标签:c,sql-server,sql-server-2008-r2,database-restore 来源: https://codeday.me/bug/20190706/1398296.html