我想在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'";