Hi John,
My ultimate goal is to should verify the SQL connection string and find out whether the sql server application is running at port number 1433. If not, I want to terminate the installation process immediately.
Most packages use a predefined connection. A connection string is mostly used by advanced users with complex configurations. In both cases, the SQL configuration can be verified through our TestODBC connection custom action (the how-to mentioned by Mihai).
Regarding the SQL Server port, I'm afraid that there is no built-in support for detecting it. Most installers use this configuration:
- add SQLConnectionDlg dialog in Dialogs page
- use its properties in your SQL connection information
- on the Next button of this dialog you can configure an SQL connection test using the same properties
- installation can be performed only if the test succeeds (the SQL connection information is correct)
Our
Using SQL Scripts tutorial explains how to add the dialog and use it. The next step would be to setup the connection test on Next button. This way you can provide 1433 as default port and the user can change it if his SQL Server uses a different one.
If you really want to use only port 1433, you can try this approach:
- write a
custom action which detects the SQL Server port (you will need to use custom code)
- schedule it before "InstallUISequence" -> "LaunchConditions"
standard action
- save the port in an
installer property
- use this property as a
custom launch condition
In this case you don't need to test the connection.
Please note that only Win32 DLL and VBScript custom actions can set installer properties. Our user guide contains a
sample C++ DLL custom action which may help you.
Also I need to terminate the installation process if any of the connection string component is wrong. Or I need to do any change any change in the connection string to validate the string and port simultaneously?
If you want to test the connection string, you cannot stop the installation. You can only prevent the user from continuing (he will cancel manually). If you don't test the string and use only a custom action to verify the port, the custom launch condition will stop the install automatically.
If the SQL Server is not connecting through the string, then I want to check whether the port number 1433 is free or not?
Our SQL connection testing mechanism was not designed for this. It tests the port specified by you or by the user. Usually the installer has a default port which the user can modify through SQLConnectionDlg.
Regards,
Cosmin
FOLLOW US
Get the latest news in Application Packaging