Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Browse for SQL script then run it

Hi,

I am trying to make away for the user to Browse for a license file and then run this file during the installation. The license file is a SQL Script. I have managed to create a way for the user to browse for the file however I can’t find a way of making it run. Any help would be much appreciated.

Matt
Bogdan
Posts: 2794
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Browse for SQL script then run it

Hi Matt,

Advanced Installer offers support for running SQL scripts. However, you would have to provide the SQL script when building the package, not when running it.

The only solution to run a SQL script which you select at runtime is to create your own custom action that runs it. You can use an EXE, VBScript, JavaScript or C++ DLL as a custom action.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Re: Browse for SQL script then run it

Hi,

I have created a Batch script that uses the SQLCMD tool to run the script however the Script contains Variables that the user is to enter the script I have screated is:

Code: Select all

sqlcmd -S "%1" -d "%2" -i "%3"
The % marks are where the variables are. What I need the user to enter is:

SQL Server Name
Database Instance Name
File Name

This will make the script look like:

Code: Select all

sqlcmd -S "<SQL Server Name>" -d "<Database Instance Name>" -i "<File Name>"
So do you know a way of entering these variables into the script. I have already made these variables in advanced installer and they all work I just need to know how I can insert them into the script through a custom action.

Matt
Matt
Bogdan
Posts: 2794
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Browse for SQL script then run it

Hi,

The following article shows how to run a batch file. To pass parameters in abatch file from what I know you need to simply write them after the name of the file, in the command line.

So, as explained in the above article you can try this value for the Command Line field:

Code: Select all

"[#MyBatchFile.bat]" [SERVER] [DB_NAME] [FILE_NAME]
Where SERVER, DB_NAME, FILE_NAME are public properties in which you store the desired values. Please note that you need to use only uppercase letters in their names in order to be valid public properties.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Matt
Posts: 109
Joined: Tue Oct 19, 2010 4:54 pm

Re: Browse for SQL script then run it

Hi,

This Seems to be working ok.

Cheers for your help

Matt

Return to “Common Problems”