I am using help of SqlServer.Management.Smo to rename an attached MS-SQL database.
Dim db As New Database = ActiveSQLServer.Databases(OLD_NAME)
db.ExecuteNonQuery("ALTER DATABASE " & OLD_NAME & " SET SINGLE_USER WITH ROLLBACK IMMEDIATE")
db.ExecuteNonQuery("ALTER DATABASE " & OLD_NAME & " MODIFY NAME = " & NEW_NAME)
The problem is that after renaming the database is set as a Single User.
So what am i doing wrong?