aevans
Posts: 3
Joined: Fri Aug 10, 2007 9:18 am

SQL Script Condition is begin ignored

Hi,

We have a pretty basic installer which installs a load of files, and some services, creates a database and populates some tables.

We have put an extra button inthe SQLConnectionDlg allowing the user to Skip the database setup.

We have a Property set in the "Install Parameters" screen, called SkipDBSetup, default 0.

When the "skip" button is clicked on the SQLConnectionDlg screen, we set the SkipDBSetup to 1.

In the SQL Scripts section, we have set all of the conditions to "SkipDBSetup = 0", however the installer tries to run the SQL Scripts regardless of what SkipDBSetup is set to. We added a custom action on the SetupTypeDlg, so that when the "Complete" button is clicked, it displayed the SkipDBSetup property, and it was set as expected.

We have already spent too long looking at this issue, so any help would be greatly appreciated!

Thanks in advance,

Andy
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Note that the properties you use should be public (no lower-case letters, for example you should use SKIPDBSETUP). This is because private properties are not modified from UI to Execute sequence.

In order to skip the SQL Database setup you select the skip button, in the "Control" section, "Published Events" tab, you should have the following events:

Code: Select all

____Event_____|___Argument__|___Condition___
[SKIPDBSETUP] |      1      |  AI_INSTALL
NewDialog     |   FolderDlg |  AI_INSTALL AND SKIPDBSETUP=1
The first control event is set using the SetProperty function and the second one jumps to the dialog which is after the database setup ("FolderDlg" for example).

You should see the following example on how to conditionally display a dialog for another approach:
http://www.advancedinstaller.com/user-g ... ialog.html

Regards,
cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
schwarzsurfer
Posts: 49
Joined: Wed Feb 10, 2016 11:06 am

Re: SQL Script Condition is begin ignored

Hello,

I also have trouble with the SQL condition.

I want to create database entries with a SQL script only if the database does not exist.
I created a property named DBEXISTS with a default value "default". Then I created a SQL Query that checks, if the database exists and if it exists it selects it's name and stores it into DBEXISTS property:

Code: Select all

IF NOT EXISTS (SELECT name FROM master.sys.databases WHERE name = N'DBNAME')
	print 'no database'
ELSE
	SELECT name FROM master.sys.databases WHERE name = N'DBNAME'
GO
I added a condition to he database SQL script: 1 AND DBEXISTS = "default" But it ignores the condition and doesn't launch the script. If I change the condition to 1 AND DBEXISTS = default it works - but I guess that's not correct, is it?

I also tried to inverse the condition like 1 AND DBEXISTS <> "DBNAME", but then it always executes the script, even if the database was found and the DBEXISTS property is set to the DB's name... but it shouldn't.

Is this an Advanced Installer iusse or am I doing anything wrong?!

Thank you so much!

Marian
Ich weiß, dass ich nichts weiß!
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: SQL Script Condition is begin ignored

Hello Marian,

I'm not so sure why this happens.

Can you 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?

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

Return to “Common Problems”