private void RestoreNew() { Server srv = default(Server); srv = new Server("ServerName"); Database db = new Database(srv, "mydb"); //srv.Databases["mydb"]; Restore rstDatabase = new Restore();
rstDatabase.Database = db.ToString();
BackupDeviceItem bkpDevice = new BackupDeviceItem(System.IO.Path.GetFileName(flRestore.PostedFile.FileName), DeviceType.File); rstDatabase.Devices.AddDevice(bkpDevice.Name, DeviceType.File);
rstDatabase.Action = RestoreActionType.Database;
rstDatabase.ReplaceDatabase = true;
rstDatabase.ContinueAfterError = true;
rstDatabase.SqlRestore(srv);
}