I want to restore a database in C #, use the .BAK file type
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();
I get an error in the line cmd.ExecuteNonQuery();
'TEST' is not a recognized RESTORE option.
Can you tell me that I am wrong or wrong.?
source
share