knyazs
Posts: 2
Joined: Sat May 18, 2024 9:26 pm

How to Execute SQL on Uninstall

Dear Community,

I need to execute an SQL statement to update a specific field in a table once the uninstallation process completes successfully.

I attempted to use the SQL Action in the 'Install Execution Stage' of custom actions but the account configured for database connection in the properties could not log in during the installation. I also tried the 'Finish Dialogs Stage' but it seems the uninstallation process does not reach this stage.

Could you please assist me in finding a solution to execute the SQL statement after the uninstallation?

Thank you,
Catalin
Posts: 6732
Joined: Wed Jun 13, 2018 7:49 am

Re: How to Execute SQL on Uninstall

Hello and welcome to our forums,

In order to achieve what you want, the properties that you are using at install time to connect to the database must be set as "persistent".

Another way would be to connect to the database using a script custom action (e.g. PowerShell) and then run the query you need.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
knyazs
Posts: 2
Joined: Sat May 18, 2024 9:26 pm

Re: How to Execute SQL on Uninstall

Hi Catalin,

Thank you for your answer.

Even after persisting, I am getting an error if I call SQL in 'Install Execution Stage'. Where would be the proper place to call SQL?
Catalin
Posts: 6732
Joined: Wed Jun 13, 2018 7:49 am

Re: How to Execute SQL on Uninstall

Hello,

If possible, could you please give me some more details about the error you are encountering when trying to execute your SQL Script?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”