Joshr
Posts: 33
Joined: Mon Dec 14, 2015 5:40 pm

Enhanced UI breaks SQL Script Replacements

Whenever I enable "Enhanced User Interface" in the Theme settings, my installations fail with SQL Errors during the InstallExecute sequence. If I disable Enhanced UI, the SQL Scripts execute as expected. I've tracked this down to the errors always being around where text replacements are supposed to have occurred. It looks like when Enhanced UI is used, it always replaces the text in the SQL script with an empty string.

I believe this may be related to issues others have reported where certain properties are not being passed to the execute sequence. In my case, these are properties set by a custom action I have written. The custom action, which executes during the UI Sequence, takes user input values (like SQL Database Name) and quotes them to be safely inserted into SQL scripts (i.e. DbName becomes [DbName], and "Database's Value" becomes "'Database''s Value'").

To reproduce this:

1) Create a new installer with a Dialog that prompts for SQL Connection Information
2) On the 'Next' button, execute a custom action which quotes the DATABASE_NAME name property into DATABASE_NAME_IDENTIFIER (Changes 'DatabaseName' to '[DatabaseName]'; I had to write a DLL for this)
3) Add a SQL Server connection and SQL Script "use $(DATABASE_NAME_IDENTIFIER)"
4) Add a text replacement to the script to replace $(DATABASE_NAME_IDENTIFIER) with [DATABASE_NAME_IDENTIFIER]
5) Enable the Enhanced User Interface
6) Run the install

You should get a SQL Error stating "Invalid syntax near 'use'"

If you disable Enhanced User Interface (and undo all the automatic changes it did), the script will execute without any errors.
Joshr
Posts: 33
Joined: Mon Dec 14, 2015 5:40 pm

Re: Enhanced UI breaks SQL Script Replacements

I was able to work around this by declaring all of the properties my custom actions could set in the "Install Parameters" section of the installer.

On a related note, I find it strange that Advanced Installer will not let me add a property with an empty value, even though I can manually add one to the table or manually edit the project file (with no issues) and AI itself adds numerous empty properties. You can see them both in the property table and when you check the "Show properties with empty value or used in dialog controls".
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Enhanced UI breaks SQL Script Replacements

Hello,

Indeed, this happens due to a limitation of our "Enhanced User Interface" feature. Due to its design our EUI feature cannot track down the properties which are not defined in the MSI database, but they are created and initialized directly within a custom action. As a workaround, to avoid this limitation you can just add your property (DATABASE_NAME_IDENTIFIER) in "Install Parameters" page.
On a related note, I find it strange that Advanced Installer will not let me add a property with an empty value, even though I can manually add one to the table or manually edit the project file (with no issues) and AI itself adds numerous empty properties.
This is because all properties added in "Install Parameters" page are inserted in the "Property" table of the MSI installation database. The "Value" column of the "Property" table doesn't accept empty strings.

If you have any questions just let us know.

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

Return to “Common Problems”