Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Not applicable

IF condition in an ODBC connect

Hi there

I develop the QV apply on my computer, and for this state, my appli feed itself with a database A.

When I've finished the apply, I transfert it on a windows server, and then, the apply should have to feed itself on a database B.

I think this is possible to test the server or whatever, with an IF condition, to execute one or the other connexion to the right database.

Like :

if ("I'm on my computer") {

     ODBC CONNECT TO [my_odbc_connexion_A];    

}

else {

     ODBC CONNECT TO [my_odbc_connexion_B];

}

But I don't know what I'am suppose to test on ? the IP ? the machine's name ?

Thanks for reading a french problem, excuse my president, and have a nice day

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

IF condition in an ODBC connect

Hi,

I think ComputerName + OSUser is a good combination:

IF (ComputerName() = 'SRV00042' AND OSUser() = 'MI6\agent007') THEN

...

ELSE

...

END IF

- Ralf

4 Replies
MVP & Luminary
MVP & Luminary

IF condition in an ODBC connect

Hi,

I think ComputerName + OSUser is a good combination:

IF (ComputerName() = 'SRV00042' AND OSUser() = 'MI6\agent007') THEN

...

ELSE

...

END IF

- Ralf

christophebrault
Valued Contributor

IF condition in an ODBC connect

Hi,

I have this situation in an application where i have to know on wich server i am. I use a text file to store the name of the environment. I Load the file and then use the result in the if statement.

LOAD Environment

FROM MyFile.txt

if (Environment='A') {

     ODBC CONNECT TO [my_odbc_connexion_A];   

}

else {

     ODBC CONNECT TO [my_odbc_connexion_B];

}

Not applicable

IF condition in an ODBC connect

Thank you both of you for your proposal.

I'm gonna test this, and get back to say the result

Not applicable

IF condition in an ODBC connect

@christophebrault : I will use your method as I use a config.php file for websites, but not for now, I don't have much skill to use this in QV apply 

@Ralf Becher : so I decide to use your way, and to know the machine's name or the user, I've learn this (for other n00b like me)

Create a text-objet, and write this : =ComputerName() , the "=" symbol will print the value in the objet.

And the same for the OSUser() function.

Both of your way is good, so, again, thank you