Codename K
Posts: 471
Joined: Fri Jan 29, 2010 3:04 pm

Removing SQL Server database while uninstalling?

Hello,

I have set the following SQL Script to remove the database when uninstalling,

Code: Select all

USE master
GO
ALTER DATABASE MyDatabase
SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
DROP DATABASE MyDatabase;
This works fine in SQL Management Studio and removes the database. But when run through the installer it does not remove the databse. I get the time out error message. How to remove the database when uninstalling?

:?:
K
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Removing SQL Server database while uninstalling?

Hello K,

I have tested your script on uninstall and it seems to run fine.

Since you are receiving a time out error this could mean that the installer does not successfully connect to your SQL Server in order to run the script. This means that the SQL Connection string parameters used to connect are not correct or non-existent.

Please note that there could be the case when on uninstall the user do not input the SQL Connection parameters and the value set for those parameters at install time is not preserved on uninstall too.

If you are using properties to store the parameter values I would recommend that you to go to the "Install Parameters" page and check the "Show properties with empty values or used in dialog controls" checkbox. Double click on the properties used to store the SQL Connection string parameters and check the "Set persistent property" option. This way the information used for the connection is saved and can be used to run the script on uninstall.

If this is not the case you are facing with, please send us the .AIP (project) and a verbose log of the installation to support at advancedinstaller dot com so we can investigate them.
All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Codename K
Posts: 471
Joined: Fri Jan 29, 2010 3:04 pm

Re: Removing SQL Server database while uninstalling?

If you are using properties to store the parameter values I would recommend that you to go to the "Install Parameters" page and check the "Show properties with empty values or used in dialog controls" checkbox. Double click on the properties used to store the SQL Connection string parameters and check the "Set persistent property" option. This way the information used for the connection is saved and can be used to run the script on uninstall.
This worked. Thank you.
K
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Removing SQL Server database while uninstalling?

You're always welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”