Revenera logo

When you add connections in the SQL Scripts view in InstallShield, your installation displays the SQLLogin dialog at run time. When end users click the Browse button next to the target server field on the dialog, the SQLBrowse dialog opens; this dialog provides a list of available servers on local and network machines. In some cases, you want to hide some specific instances from the list of servers. For Basic MSI projects, you can accomplish this by writing a custom action that removes items from the IS_SQLSERVER_LIST ListBox control. This VBScript example illustrates removing all of the named instances from the list starting with SQLEXPRESS.

Const msiViewModifyDelete = 6

Const IDOK = 1

‘ open and execute a view to the ListBox table

Set viewlist = Database.OpenView(“SELECT * FROM `ListBox` WHERE `Property`=’IS_SQLSERVER_LIST'”)

viewlist.Execute

Set reclist = viewlist.Fetch

While Not (reclist Is Nothing)

    If InStr(reclist.StringData(4), “SQLEXPRESS”) <> 0) Then

         ‘ delete the ListBox record

         viewlist.Modify msiViewModifyDelete, reclist                                                                                                        

    End If

    ‘ fetch the next ListBox record

    Set reclist = viewlist.Fetch

Wend

‘ clean up

viewlist.Close

InstallShield icon

InstallShield

Create native MSIX packages, build clean installs, and build installations in the cloud with InstallShield from Revenera.

You need to execute this code by a VBScript custom action after the list of servers is created and before the SQLBrowse dialog is displayed by following steps below.

  1. In InstallShield, open a Basic MSI project that includes a SQL connection that you configured through the SQL Scripts view.
  2. Create a custom action that removes the named instances from the list of servers:
    • In the View List under Behavior and Logic, click Custom Actions and Sequences.
    • Right-click the Custom Actions explorer, point to New VBScript, and then click Store in custom action.
    • Name the new custom action RemoveSqlExpressInstances.
    • On the Common tab, keep all of the default settings.

Hidblog

 

  • On the Script tab, enter the aforementioned sample VBScript.

3.  Edit the SQLLogin dialog to call the custom action when an end user clicks the SQLLogin dialog’s Browse button:

  • In the View List under User Interface, click Dialogs.
  • In the Dialogs explorer, under the All Dialogs node, expand the SQLLogin dialog node.
  • Under the SQLLogin dialog node, click the Behavior node.
  • In the SQLLogin Dialog Behavior grid, click the BtnSQLBrowse PushButton control.
  • In the BtnSQLBrowse PushButton grid, click the Click here to add a new item row, and enter the following values:
  • Event:          DoAction
  • Argument: RemoveSqlExpressInstances
  • Condition:  1
  • Right-click the event that you added in the previous step, and click Move up to sequence the event immediately after the event calling the  ISSQLServerList action.

Hidor2

4.  Build your installation.

If anyone has any comments or questions, please let me know!