Roberto
Posts: 13
Joined: Wed Jun 24, 2015 4:52 pm

Uninstall - Issue on deleting database

Hello,
my AI is Enterprise version.

In my application I need to install: web application, web service, windows service all connected with database Sql Server. The installation works fine.

The uninstall all fine except the database deletion: I need to delete the database from Sql Server but does not work.
I created an Sql script that runs on Uninstall. The uninstall process deletes the database before the services. This is a problem because the database is already in use and the process cannot drop the database.
How can I move the deletion of the database at the end of all other processes?

You can see the Sql script list in the attached file. The second row (Eliminazione DB e USER) doesn't not work in that position.

Thanks in advance.
Roberto
Attachments
Cattura.PNG
Cattura.PNG (13.67 KiB) Viewed 3516 times
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Uninstall - Issue on deleting database

Hello Roberto and welcome to our forums,

This happens because all SQL Scripts added on our "SQL Databases" page are executed on uninstall (by a predefined Advanced Installer action) before the services are stopped and removed.This is our default behavior.

To achieve what you want you can use an SQL Query instead of an SQL Script. An SQL Query is an SQL script whose execution is triggered by the execution of a "Query SQL database for data" custom action. So, the query will be executed when its associated custom action is scheduled. Therefore after adding the "SQL Query" you should go to "Dialogs" page and schedule its associated custom action after "Install Execution Stage -> Remove Resources" action group and configure it to run as deferred.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Roberto
Posts: 13
Joined: Wed Jun 24, 2015 4:52 pm

Re: Uninstall - Issue on deleting database

Hello Daniel and thanks for your reply.

I tried yesterday something similar to your solution. I readed something of similar in another thread in the forum. The only difference was that I not used the differed option.
Now I'm trying to follow your explanation but doesn't works. Attached you can find images of my configuration (the variables are persistent in the registry)

Anyway, I resolved the issue with the script (image number 2) that runs on uninstall: the script sets the DB offline and next set it online.
This is a trick, but it would be better to try to use the correct configuration.
I will read more about this feature.

Thanks and regards,
Roberto
Attachments
Cattura3.PNG
Cattura3.PNG (25.59 KiB) Viewed 3490 times
Cattura2.PNG
Cattura2.PNG (60.35 KiB) Viewed 3490 times
Cattura.PNG
Cattura.PNG (107.52 KiB) Viewed 3490 times
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Uninstall - Issue on deleting database

You're always welcome Roberto.

If you encounter any further issues please send us the .AIP (project file) and a verbose log of the installation to support at advancedinstaller dot com so we can investigate them. Also, try to give us more details about the behavior you are encountering and about the one you are trying to achieve.

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

Return to “Common Problems”