Answer
You can choose to let the installing user select an SQL Database to connect to, from the available databases on a Microsoft SQL Server. Advanced Installer can automatically connect to the SQL Server using the provided credentials and enumerate all databases the user is allowed to connect to.
Launch the "Browse SQL Databases"
wizard from the SQL toolbar and follow the instructions.
Add the Advanced Installer "SQLConnectionDlg"
to the dialogs tree. Create a new dialog (eg. "SelectDBDialog") after
the previous one. We can setup this second dialog to receive the list of
enumerated databases that the user is allowed to connect to.
You can use this functionality with any other dialog of your choice,
or you can customize the Advanced Installer built-in dialog.
Optionally, instead of using a fixed (predefined) instance of SQL Server, you can let the user pick an SQL Server to connect to, from the available Microsoft SQL Servers on the network. You can find detailed instructions on how to accomplish this, here. A wizard that can assist you can be launched from the "Predefined custom actions" menu in the Custom Actions page.
Input properties
The following input parameters must be specified through Windows Installer properties. These properties can be set statically (from Install Parameters) or dynamically (from the installer UI - associated with Edit Controls or with SetProperty Initialization/Published Events).
- ODBC_RES_PROP - ODBC driver name (default: "SQL Server")
- SERVER_PROP - SQL server name or instance name (default: "(local)")
- USERNAME_PROP - logon user name
- PASSWORD_PROP - logon password
- SqlTrustedConnection - use a trusted login connection (local/domain)
If you set the SqlTrustedConnection property
to 1 , the credentials of the installing user
will be used and the USERNAME_PROP/PASSWORD_PROP properties are no
longer necessary.
Based on the credentials provided by the installing user (directly or indirectly), Advanced Installer will try to connect to the specified SQL server and discover which of the available databases the user is allowed to connect to.
Connection Timeout
(Optional) You can specify a connection timeout (in seconds) for the browse operation. The default is 60 seconds. The timeout can be specified through the Windows Installer property SqlConnectionTimeout. You can set this property statically (from Install Parameters) or dynamically (from the installer UI - associated with an Edit Control or with a SetProperty Initialization/Published Event).
You can suppress the spawned message box for the SQL
Server browse operation by setting the
SqlSuppressSpawnMsgBox property to 1
. You can set this property statically
(from Install Parameters) or
dynamically (from the installer UI - associated with an Edit Control or with a SetProperty
Initialization/Published Event).
Finally, add an Initialization/Published Event with the following settings:
- Name: DoAction
- Argument: ShowDatabases (the name of the custom action you created earlier)
- Condition: 1

Database discovery result (output)
The following output properties will be used by Advanced Installer to return the discovered available databases:
- Any ComboBox control that has the property SqlServerDatabaseComboBox associated with it.
- Any ListBox control that has the property SqlServerDatabaseListBox associated with it.
- Advanced Installer "SQLConnectionDlg": you can replace the Edit control (DatabaseEdit) with a ComboBox control that has the same DATABASE_PROP property attached to it.
- A flat, comma separated list of SQL databases (names only) will be dumped into the SqlServerDatabases property. You can use this value if you wish to do any custom processing of the databases list.
Sample Project
You can find a small sample Advanced Installer project implementing the above
functionality here.
See also: Browse for SQL Servers and
Test SQL Connection