1

I have a SSAS Tabular server with 30 database.

I also have a scheduled process to backup all databases daily.

When I run the process which is an SSIS package with script task using AMO, I get this error :

The 'Database' with 'ID' = 'nameofdatabase' doesn't exist in the collection.

The backup process is running under the service account credential and it successfully backs up 27 databases but fails for only 3 of them.

I checked those databases and don't see anything special on them.

I googled the error message and most of the issues are related to deploying or processing the database. I don't see any reason for failing the backup.

What is the problem and how I can resolve this issue?

4

One thing that could cause this is if you use the Name of the database instead of the ID.

For example, I created a database with with the name Demo1, so the ID defaulted to the same string.

Afterwards I renamed the database, but that doesn't change the ID.

If your AMO script uses the name string instead of the ID string that could cause this error.

enter image description here

1

As Tom V mentioned I need to use Name instead of ID in my C# AMO code.

currently my code is

Server server = new Server();
server.Connect(@"data source=" + asServer);
Database db = server.Databases[dbName];
db.Backup(
    new BackupInfo
    {
        AllowOverwrite = true,
        ApplyCompression = true,
        File = fileName
    }
    );

server.Databases[dbName] searches the collection with ID of the database. To use Name for finding the database I need to use below code

Database db = server.Databases.FindByName(dbName);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy