Does InstallBuilder have any built-in ability to test a connection to a database using the credentials entered?

asked 15 Mar '12, 16:33

bstoke's gravatar image

bstoke
16222224
accept rate: 0%


InstallBuilder do not have a built-in method to validate the connection but you could call the client binary from a <runProgram> action:

                      <actionGroup>
                            <abortOnError>0</abortOnError>
                            <showMessageOnError>0</showMessageOnError>
                            <actionList>
                                <setInstallerVariable name="connection_validated" value="0" />
                                <runProgram>
                                    <program>${mssql_client}</program>
                                    <programArguments>-U${mssql_root_user} -P${mssql_root_password} -S${mssql_dsn} -Q "exit"</programArguments>
                                </runProgram>
                                <setInstallerVariable name="connection_validated" value="1" />
                            </actionList>
                        </actionGroup>
                        <throwError>
                            <text>Unable to connect to database ${mssql_dsn} as a ${mssql_root_user} database user. Please check your configuration.</text>
                            <ruleList>
                                <isFalse value="${connection_validated}" />
                            </ruleList>
                        </throwError>

Where mssql_dsn would be ${env(COMPUTERNAME)}\\${mssql_instance} and the mssql_instance can be the result of a choiceParameter, populated from the registry:

<registryFind>
  <findAll>1</findAll>
  <keyPattern>*</keyPattern>
  <namePattern>*</namePattern>
  <rootKey>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL</rootKey>
  <searchDepth>1</searchDepth>
  <variable>mssql_info</variable>
</registryFind>
<foreach>
  <values>${mssql_info}</values>
  <variables>key name value</variables>
  <actionList>
     <addChoiceOptionsFromText>
       <name>mssql_instance</name>
       <text>${value}=${value}</text>
     </addChoiceOptionsFromText>
     </actionList>
  </foreach>
link

answered 16 Mar '12, 06:10

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×3
×3
×1

Asked: 15 Mar '12, 16:33

Seen: 1,611 times

Last updated: 16 Mar '12, 06:10