“System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing ‘database_name’ database. (Microsoft.SqlServer.Smo)”
If you already have a database with the same name as the database that you want to restore, and you have a database that is different from the database you want to restore, you will get this error.
For example, you have a database named “qw” in SQL Server Instance. You also have a backup file (aa.bak) of the database “aa”. If you try to restore this backup file by using the “qw” database name in your SQL Server Instance, you will get this error. Because they are two different databases.
Therefore, for the backup of the “aa” database you are trying to restore, either use the name “aa” as the database name, or use a database name that does not exist in the SQL Server Instance that you are currently working on.