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

Optional Create Database

Hi,

We would like the user to be able to install the database optionaly as if they are just trying to install one feature such as the web site or the Service we dont want another database installing. I know how to set the scripts to run only if the database is selected.

However on the SQL Connection it is creating a database no matter what we do.

Is there a way of creating the database only when we want to? Maybe getting it to run a SQL Script that just says Create database <DBNAME>?

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

Re: Optional Create Database

Hi,

Just an update on this I found out that If I set all the SQL Scripts on a Connection to only execute if the database is selected then the Connection wont create a database. I would just like you to clarify that this is ok and wont cause any issues.

Matt
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Optional Create Database

Hi Matt,

Usually a database name is specified in the connection string if you want to execute certain SQL scripts on that database. There might be some cases when it doesn't exist so we added the option "Create database if it does not exist" to prevent this.

If you want to conditionally create a database then simply add a connection without specifying the database. Then add an SQL script that creates it, with the required script condition:
http://www.advancedinstaller.com/user-guide/sql.html

This way the connection to the server will be established and the SQL script will be executed( thus creating the database ) only when its condition is met.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”