The following article uses options that are available starting with the Enterprise edition and project type.
This tutorial uses the predefined SQLConnectionDlg dialog and all the settings will be collected during install time and then passed to the installer. In order to do this public properties will be used.
Go to Dialogs Page and select FolderDlg dialog. Select “Add Dialog” toolbar option or “Add Dialog...” context menu option.
The Add Dialog dialog will appear. Select SQLConnectionDlg from the list and press "OK". The new dialog will be added in the chain after the FolderDlg dialog.
In the SQLConnectionDlg dialog select the "ODBC Resource" static text control and from the Properties pane located in the right side, set the Visible attribute to False.
Repeat the same procedure for the edit box control associated with "ODBC Resource".
In order to connect to a MySQL Server a compatible ODBC driver is required. In this tutorial, we will assume the MySQL ODBC driver is already installed on the developer machine.
The MySQL ODBC driver can be download, for free, from MySQL website as installer or source files packages.
Once the MySQL ODBC driver has been downloaded it can be set as a prerequisite package. This way the installer will check if the ODBC driver is installed on the target machine and if not, it will install it.
If the source files have been downloaded the driver can be installed by this package using the ODBC page. For information on how to install an ODBC driver please see the Configure an ODBC Driver section from our tutorial.
This will change the installation type to "Per-machine only".
Rename the connection to something meaningful. Using the "SQL Connection" properties pane from the right side, write the following settings:
|Connection Type||MySQL Server|
|Connection Mode||ODBC Driver|
|ODBC Driver||MySQL ODBC 5.1 Driver (or the one installed on the machine)|
|Use a property to set password||[PASSWORD_PROP]|
Since we are going to use this connection with MySQL Server we will not use a property to set the "ODBC Driver" parameter and we will hard-code it instead.
Add all the necessary resources like files and folders to the project, build and run it.
It is wise to test if the package is correctly connecting to MySQL Server before giving it to your customers.
The Test SQL Connection How To article shows the steps needed to take in order to test your SQL connection.
Once the installation package is running navigate to the "SQL Database" dialog and enter the following information:
- The name of the SQL Server. If the server is hosted on the local machine use localhost.
- The port used by the SQL Server. By default, Microsoft SQL Server uses the 3306 port.
- The name of the database to which the install package will connect to.
- The username under which the connection will be initiated. By default, MySQL Server comes with the root user.
- The password associated with the user. For the root user this password is set during the MySQL Server installation.