Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic OLEDB Connection

Hi Guys,

Background:

I develop QVW on my local machine then upload them on Production server so users can use it via Access point.

But every-time I copy the file from my machine to the server.. I have to change the connection string.

I have created a variable in the beginning of the load script as below :

vEnvironment = 'Dev' ;

What if statement should I use in the load scrip so that if vEnvironment = 'Dev' then it should use DEV OLEDB connection string and if its 'Prod' then it should use Production OLEDB connection string

1 Solution

Accepted Solutions
Kushal_Chawda

For that Create the Variable in each root folder application.

For dev application, create the, Variable, vDev=1

For UAT application, create the, Variable, vUAT=1


For Prod application, create the, Variable, vProd=1


Now in each application write the below Condition


If $(vDev)= '1' Then

          CONNECT ... <dev connect string ...>;

     Else if $(vUAT)= '1' then

          CONNECT ... <UAT connect string ...>;

       Else if $(vProd)= '1' then

             CONNECT ... <Prod connect string ...>;

     End If

View solution in original post

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

You can open the connections condionally:

     If vEnvironment = 'Dev' Then

          CONNECT ... <dev connect string ...>;

     Else

          CONNECT ... <production connect string ...>;

     End If

Or you can use an include file with the connect string. One file in the same relative location to the qvw file on each server containing the connect statement with the connection string for that environment.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks Jonathan,

Can we add two if conditions if I add another environment in between like 'Testing' or 'UAT'

And What could be the other alternatives for changing connection dynamically based on the QVW document root?

I mean, If the document root folder name wild match = 'Test' then connect to test or dev accordingly?

Kushal_Chawda

For that Create the Variable in each root folder application.

For dev application, create the, Variable, vDev=1

For UAT application, create the, Variable, vUAT=1


For Prod application, create the, Variable, vProd=1


Now in each application write the below Condition


If $(vDev)= '1' Then

          CONNECT ... <dev connect string ...>;

     Else if $(vUAT)= '1' then

          CONNECT ... <UAT connect string ...>;

       Else if $(vProd)= '1' then

             CONNECT ... <Prod connect string ...>;

     End If

Colin-Albert

Another option is to put the connect command in an INCLUDE file, with the relevant connection settings on Dev and Prod.

Then add a MUST_INCLUDE statement to access the relevant connection details.

http://www.quickintelligence.co.uk/qlikview-include-files/

dmac1971
Creator III
Creator III

I have a similar solution to a different problem and use my machine name to resolve which data folders the script looks at when loading data :

if ComputerName() = 'MACH004' then
Set Path = '..\Sources\';
Set Store = '..\Backlog History\';

else

Set Path = 'D:\QlikView\01 Development\06 Web\Data\';
Set Store = 'D:\QlikView\01 Development\06 Web\Store\';
End If