Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

shree909
Valued Contributor II

Connecting to database Dynamically

Hi Folks,

I  have 2 odbc connections one for production, Development.

The entire script remains same  only i need to change the odbc connection depending on the computername or servername

so i did like this but its not allowing me to do in the script and throwing an error.

if i want to use the if condition in the script  how to add??

 

IF(ComputerName()='ABC','ODBC CONNECT TO [xysbef;DBQ=xysbef] (XUserId is bJKfcYZODbXKXZVMSbXEXSFMETFA, XPassword is AJWSQYZODDZCGaFMRJIQL)',

if(computername()='DEF','ODBC CONNECT TO [yeyeye;DBQ=yeyeye ] (XUserId is KTDBaYZODbXKXZVMSbXEXSFMEbeB, XPassword is eNUWRYZODDZCGaFMRJIAG)'));

so when the computername is identified it should connect to that server odbc connection.

Thanks

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Connecting to database Dynamically

Hi Shree,

just use the IF statement, not function:

IF ComputerName()='ABC' THEN

     ODBC CONNECT TO [xysbef;DBQ=xysbef] (XUserId is bJKfcYZODbXKXZVMSbXEXSFMETFA, XPassword is AJWSQYZODDZCGaFMRJIQL);

ELSEIF ComputerName()='DEF' THEN

     ODBC CONNECT TO [yeyeye;DBQ=yeyeye ] (XUserId is KTDBaYZODbXKXZVMSbXEXSFMEbeB, XPassword is eNUWRYZODDZCGaFMRJIAG)';

ELSE

     // error action

END IF

- Ralf

2 Replies
MVP & Luminary
MVP & Luminary

Re: Connecting to database Dynamically

Hi Shree,

just use the IF statement, not function:

IF ComputerName()='ABC' THEN

     ODBC CONNECT TO [xysbef;DBQ=xysbef] (XUserId is bJKfcYZODbXKXZVMSbXEXSFMETFA, XPassword is AJWSQYZODDZCGaFMRJIQL);

ELSEIF ComputerName()='DEF' THEN

     ODBC CONNECT TO [yeyeye;DBQ=yeyeye ] (XUserId is KTDBaYZODbXKXZVMSbXEXSFMEbeB, XPassword is eNUWRYZODDZCGaFMRJIAG)';

ELSE

     // error action

END IF

- Ralf

shree909
Valued Contributor II

Re: Connecting to database Dynamically

Hi  Ralf Becher,

That works perfect...

Thanks

Sree

Community Browser