Restore.Abort (SMO) throws Exception and Cannot Delete Database

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Using Restore.SqlRestore (synchronous method call) followed by calling
Restore.Abort causes the following excepion to be thrown:
Restore failed for Server 'localhost\SQLExpress'.
Operation cancelled by user.

Then tried to delete database with:
Server srv = new Server("localhost\SQLExpress")
srv.KillDatabase("MyDatabase")

Another exception was thrown shown below:
Kill database failed for Server 'localhost\SQLExpress'.
ALTER DATABASE is not permitted while a database is in the Restoring state.
ALTER DATABASE statement failed.

However I was able to delete database using SQL Server Manager Studio Express.

In addition when viewing the database in SQL Server Manager Studio Express
the database name looked like this:
"MyDatabase(Restoring...)"
It is as though the restore never completed.

Does anyone know why this would happen and what is the work around to get
the Restore.Abort to work properly?

Thanks.
 
Back
Top