amoServer.Restore(abfFile, db.Name, true);
amoServer.Databases.GetByName(db.Name).LastUpdate = db.LastUpdate;
I am copying one SSAS database from one server and to another. Since the database is restoring, the last update get set... so I want to change it back. However it appears that the collection of Databases never gets updated with the new database. I've tried .Refresh()
and .Update()
before the call, but I still get an error
Microsoft.AnalysisServices.AmoException: The 'Database' with 'Name' = 'SomeReallyLongName' doesn't exist in the collection.
Anyone ever done this before?
Try this:
amoServer.Restore(abfFile, db.Name, true);
amoServer.Refresh(true, RefreshType.LoadedObjectsOnly);
Database dbRestore = amoServer.Databases.GetByName(db.Name);
dbRestore.LastUpdate = db.LastUpdate;
dbRestore.Update();
I'm not sure setting the LastUpdate will work as you hope but I suspect you have to do a .Update() to save that change.