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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top