jstuardo
Posts: 87
Joined: Mon Nov 09, 2015 10:44 pm

Bad behaviour when using Test ODBC Connection dialog

Hello, I followed these instructions (https://www.advancedinstaller.com/user- ... ction.html) to create a Test ODBC Connection dialog to test SQL Server connection before actually application is installed.

First of all, there is a mistake in that page.

For SQL Server, connection string indicated there is:

Code: Select all

Driver=[\{]SQL Server[\}];Server=[SERVER_PROP]; PORT=[PORT_PROP];Uid=[USERNAME_PROP];Pwd=[PASSWORD_PROP];
That is wrong. The correct is:

Code: Select all

Driver=[\{]SQL Server[\}];Server=[SERVER_PROP],[PORT_PROP];Uid=[USERNAME_PROP];Pwd=[PASSWORD_PROP];
Well... but the problem is that when implemented in my own installer, and when clicked "Next" button, if the connection fails, the ODBC error message is shown and the same dialog is kept.

So far, so good.

However, when the connection succeeds, the same dialog is kept. I have to click "Next" button again. In that case, the connection is tested again and finally, the next dialog is shown.

I am attaching the AIP file.

Any help will be appreciated, thanks

Jaime
TestSQLServerConnection.png
TestSQLServerConnection.png (111.01 KiB) Viewed 4642 times
Attachments
Control de Visitas 3.aip
(93.98 KiB) Downloaded 220 times
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Bad behaviour when using Test ODBC Connection dialog

Hello Jaime,
First of all, there is a mistake in that page.
That is not actually a mistake.

Most of the time, the default PORT (1433) is used, therefore it is not a must to specify the PORT in the SQL Connection String.
However, when the connection succeeds, the same dialog is kept. I have to click "Next" button again. In that case, the connection is tested again and finally, the next dialog is shown.
Indeed, you are right here.

To avoid such a behavior, you can add one more control to your dialog ("Push button" type) to which you can attach the "Test ODBC connection" custom action together with the "Set property" event which sets the SqlConnectionString.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jstuardo
Posts: 87
Joined: Mon Nov 09, 2015 10:44 pm

Re: Bad behaviour when using Test ODBC Connection dialog

Catalin wrote: Thu Feb 20, 2020 10:46 am
First of all, there is a mistake in that page.
That is not actually a mistake.

Most of the time, the default PORT (1433) is used, therefore it is not a must to specify the PORT in the SQL Connection String.
But when port is used, connection string you have shown is incorrect.
Catalin wrote: Thu Feb 20, 2020 10:46 am
However, when the connection succeeds, the same dialog is kept. I have to click "Next" button again. In that case, the connection is tested again and finally, the next dialog is shown.
Indeed, you are right here.

To avoid such a behavior, you can add one more control to your dialog ("Push button" type) to which you can attach the "Test ODBC connection" custom action together with the "Set property" event which sets the SqlConnectionString.
It means instructions in your page are useless? I think you may consider changing it to use the procedure you wrote here.

I have added a button and it works, but I think why the first way does not work.

I have added a control condition in the Next button with the action Disable:

Code: Select all

NOT (SqlConnectionOK = "1")
And for Enable:

Code: Select all

SqlConnectionOK = "1"
When I test odbc connection and it succeeds, Next button is not enabled. It is enabled after other event is thrown.

I have realized about this because I have a other checkbox which has a control condition. After that other event is thrown, the Next button is enabled.

In summary, SqlConnectionOK variable does not become 1 immediately when the connection succeeds. It is set 1 when other event is thrown.

I am pretty sure this is the problem when the same dialog is kept when the test connection is attached to the Next button.

Is there a way to solve this? I need to enable Next button if and only if the connection succeeds.

Kind regards,

Jaime
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Bad behaviour when using Test ODBC Connection dialog

Hello Jaime,
I have added a control condition in the Next button with the action Disable:
Instead of this, I think you could simply click on the "Next" button and have it disabled by default (from the right pane --> "Attributes" --> "Enabled" set to "False") and simply add a control condition on it to enable when

Code: Select all

SqlConnectionOK = "1"
condition is satisfied.
When I test odbc connection and it succeeds, Next button is not enabled.
This is pretty strange, indeed.

I have tested this just now and the button was enabled as soon as I have pressed the button which triggers the "Test ODBC Connection" custom action.

In order for me to have a better look about this, please forward me a copy of the .AIP file (with the custom action implemented).

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jstuardo
Posts: 87
Joined: Mon Nov 09, 2015 10:44 pm

Re: Bad behaviour when using Test ODBC Connection dialog

Hello Catalin,

Finally it worked with the Next button. I don't know what happened before, but not, when Next button is pressed, the connection is tested and if succeeds, the next dialog is shown.

I have other question regarding this and about the "(local)" problem.

In order to call TestODBCConnection custom action, the connection string should have be called actually "SqlConnectionString".

If there a way to have other name?

I ask you because I need to use this connection string when SERVER_PROP is (local):

Code: Select all

Driver=[\{]SQL Server[\}];Server=[SERVER_PROP];Trusted_Connection=Yes;
And this connection string in other case:

Code: Select all

Driver=[\{]SQL Server[\}];Server=[SERVER_PROP],[PORT_PROP];Uid=[USERNAME_PROP];Pwd=[PASSWORD_PROP];
I need to create 2 connection strings but with different name. Or, can I have the same property name but with different conditions?

Regards
Jaime
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Bad behaviour when using Test ODBC Connection dialog

Hello Jaime,

First of all, please accept my apologies for such a delayed reply, we've been pretty busy lately.
Finally it worked with the Next button. I don't know what happened before, but not, when Next button is pressed, the connection is tested and if succeeds, the next dialog is shown.
I am really glad you got this working.
I have other question regarding this and about the "(local)" problem.

In order to call TestODBCConnection custom action, the connection string should have be called actually "SqlConnectionString".

If there a way to have other name?
To be fully honest with you, I am not quite sure it is possible to have another name. However, I was thinking that maybe you can set the "SqlConnectionString" property based on your condition. For instance, have two "Set property" events that will set the property based on your condition.

Hope this helps.

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

Return to “Building Installers”